This question comes from a debate with my friend. She says this sentence must be valid and gives an example of the Visual Studio string: "Close all but this".

I think the Visual Studio string makes sense since we are excluding a subgroup of a generalized group. However I can't really tell what is the exact meaning of but here and whether we can use it to exclude anything.

It would be valid as "I like dogs, but cats..." (followed by an exasperated sigh). But you are correct that the VS example is qualifying "all", whereas "cats" is not qualifying "dogs" but is an entirely separate term.
– Hot LicksApr 17 '15 at 12:26

The funny thing is that if you try to emulate Visual Studio and you say, "I like all but cats", it has a wholly different meaning.
– Mr ListerApr 17 '15 at 18:59

8

Your friend has probably rationalized "Close all but this" as meaning "Close all but not this". From that point of view, one might also decide that "I like dogs but cats" means "I like dogs but not cats." But it doesn't work like that, as the various answers explain.
– David RicherbyApr 17 '15 at 22:38

1

"Close all but this" isn't a valid sentence either. It's just a string of words describing a menu option.
– Robert HarveyApr 19 '15 at 15:02

1

@ Robert Harvey It is valid because the meaning of "but" changes when used as a preposition. The top 2 answers give a good explanation.
– jiggunjerApr 20 '15 at 7:28

There are two different meanings and syntaxes (among others) for 'but'.

In

I like dogs, but ...

'but' is acting like a conjunction. What is expected in the ellipses is a full sentence. Using a simple noun there is really wrong and doesn't make sense. One expects something like "I like dogs, but cats really bother me".

In

Close all but this

'but' is acting like a preposition (heading a prepositional phrase) meaning 'except for'. Here a noun is expected. It is not as common as 'but' used as a conjunction, but is still used often enough (and is much shorter than 'except for', and so is useful in computer user interfaces).

So "I like dogs but cats" is not valid because cats is not a full sentence.

What I have not seen pointed out by anyone else is that this attempt at a sentence is ambiguous. It could mean at least two different things:

I like dogs but cats are also okay.

vs.

I like dogs but I do not like cats.

I'm honestly not sure which one you or your friend meant. Because of that, I would not call it a proper sentence. As such, I also would not call it "valid". The purpose of any language is to convey ideas. Always make sure that you are clearly doing so, otherwise you're not being valid.

It is a valid sentence that doesn't make sense. As someone else said the following sentence is valid:

I like all animals but skunks.

The original sentence - "I like dogs but cats" - has the same structure, so it must be valid as well, but the meaning is nonsensical. Sort of like the following sentence which is valid but makes no sense:

I'm confused. Are you saying that "I like all animals but skunks." is nonsensical?
– DCShannonApr 17 '15 at 20:46

@DCShannon I'm saying it is valid and makes sense. My point is that if you substitute each part with an equivalent part, a noun for a noun, etc. it must still be technically grammatically correct even if it makes no sense.
– NecreauxApr 17 '15 at 20:50

7

I like all animals but skunks is acceptable, but I like animals but skunks isn't.
– Edwin AshworthApr 17 '15 at 21:15

There's a difference between non-sensical meaning and invalid sentence structure. Neither of your first two examples has valid sentence structure.
– Robert HarveyApr 19 '15 at 17:04

Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).