News for hackers. Stuff that matters.
Re:If-then-else had to be invented by fouronnes3 on Sunday December 13, 2020 @10:35AM (#25407226)
Great observations. In the same idea, "or" is inclusive in all of programming and CS, i.e. A and B => A or B, but in natural languages (as least the ones I know) "or" is almost always exclusive, i.e "do you want to eat pizza or pasta?" does not imply that eating both is an option.

This is of course related to why the famous joke "Is it a boy or a girl? Yes." is so hilarious.

Re:If-then-else had to be invented by csicseri on Sunday December 13, 2020 @12:52PM (#25408441)
If you say it out loud, you will realize that the question "Do you want to eat pizza or pasta?" (exclusive-or case with the answer "pizza" or "pasta," i.e. in the sense "these are your two choices, which would you prefer?") is an entirely different utterance from "Do you want to eat pizza or pasta?" (inclusive-or case with the answer "yes" or "no," i.e. in the sense "would you like to go to an Italian restaurant?"). The first case is pronounced with primary stress on the first syllables of both "pizza" and "pasta," and with a high tone on "pizza" and a low tone on "pasta," indicating a contrast between the two alternatives. The second case is pronounced with primary stress on the first syllable of "pizza," secondary stress on the first syllable of "pasta," and a uniform tone over the phrase "pizza or pasta" on which is superimposed the rising tone on the last syllable of the sentence indicating a yes/no question. (To see that the latter is true, add "tonight" to the yes/no sentence - "would you like to eat pizza or pasta tonight?" The tone does not rise until the syllable "night.")

You have to be very careful in reasoning about natural language based solely on the written record, since spoken language regularly includes features, such as the suprasegmentals (stress and intonation) in the above examples, that aren't recorded in the orthography.

Re:If-then-else had to be invented by a1369209993 on Sunday December 13, 2020 @02:49PM (#25409519)
The first one is not exclusive-or, though: if you wanted to eat pizza and pasta, you would not answer "no" to "Do you want to eat pizza or pasta?", you would answer "both". Rather, "or" is serving as a inclusive-or with (perhaps) the incidental implication that picking more than one doesn't make sense in the first place.
Re:If-then-else had to be invented by mantap on Sunday December 13, 2020 @05:45PM (#25411176)
Do you want to eat pizza and garlic bread? - inclusive

Do you want to eat pizza or garlic bread? - exclusive

In natural language "and" works like a inclusive or. If there is pizza and garlic bread I can choose to eat one or both. Or is always exclusive in this sentence.

Re:If-then-else had to be invented by tsimionescu on Monday December 14, 2020 @06:21AM (#25415779)
With minor modifications, it can become inclusive or:

Do you want to eat some pizza or some garlic bread? - probably inclusive or

Also, I would interpret the first question as "addition" (pizza with garlic bread, on the model of mac and cheese), not as an inclusive or.

Re:If-then-else had to be invented by bryanrasmussen on Sunday December 13, 2020 @04:43PM (#25410602)
>inclusive-or case

I used to drive my friend crazy when he would ask if I wanted a peanut butter and jelly sandwich or a ham and cheese sandwich and I would answer yes.

Re:If-then-else had to be invented by benibela on Sunday December 13, 2020 @05:25PM (#25411017)
He should have given you peanut butter, and a cheese sandwich
Re:If-then-else had to be invented by MaxBarraclough on Sunday December 13, 2020 @12:45PM (#25408381)
To make things even worse, we sometimes capitalise these words to emphasise that we're using them in a technical sense, but OR reads as if it's emphasising that it's an exclusive 'or'. You can have tea OR coffee is clearly emphasising that it's an XOR operation.

Somewhat related: the Ada language uses and, or, xor for its logical operators, but uses and then and or else for the short-circuit forms. [0] Not a very natural solution in my opinion.

[0] https://en.wikibooks.org/wiki/Ada_Programming/Operators#Shor...

Re:If-then-else had to be invented by DaiPlusPlus on Sunday December 13, 2020 @01:47PM (#25408970)
VB.NET also uses “OrElse” and “AndAlso” for short-circuiting. VB6 didn’t support short-circuiting at all.
Re:If-then-else had to be invented by MaxBarraclough on Sunday December 13, 2020 @05:53PM (#25411249)
Good example, I'd forgotten about that.

On second thought I was mistaken about the example I gave. If someone says You can have tea OR coffee they're really expressing a NAND. You can have at most one out of the two options. Unlike with XOR, you're permitted to have neither.

To express XOR, you'd need to say You must have tea or coffee.

Re:If-then-else had to be invented by gpderetta on Sunday December 13, 2020 @11:16AM (#25407560)
Latin has both in inclusive ('vel') and exclusive ('aut') or.
Re:If-then-else had to be invented by hutzlibu on Sunday December 13, 2020 @11:38AM (#25407760)
"This is of course related to why the famous joke "Is it a boy or a girl? Yes." is so hilarious"

Only to IT people though. Common folks will just look at you in a weird way...

Re:If-then-else had to be invented by still_grokking on Sunday December 13, 2020 @02:54PM (#25409564)
Except the folks are mathematicians.

But in this case there is actually a slight chance that nobody recognizes this as a joke at all...

Re:If-then-else had to be invented by hutzlibu on Monday December 14, 2020 @06:34AM (#25415870)
I knew that someone would point that out..

But I figured most mathematicians are IT people, too. But there is at least also a third group: philisophers. They have formal logic, too (in university), but seldom math.

So in the spirit of the joke:

"Only to IT people though. "

Would have to be:

"Only to IT people and/or math people and/or philosophers, though. "

Desire for formal correctness satisfied?

Re:If-then-else had to be invented by etripe on Monday December 14, 2020 @09:20AM (#25417807)
It can also be used as the equivalent to a try/catch statement in most Germanic languages (including English, though Ingveonic, really) when ending a sentence with it.

"Do you like pizza, or?"

Depending on the exact statement, you might catch more or less flak.

Re:If-then-else had to be invented by cgriswald on Sunday December 13, 2020 @11:22AM (#25407619)
> "or" is almost always exclusive, i.e "do you want to eat pizza or pasta?" does not imply that eating both is an option.

English is way too ambiguous for this example and often relies heavily on context. Wanting to eat pizza does not preclude also wanting to eat pasta. If it was exclusive or, and you wanted to eat both pizza and pasta, the honest answer to this question would be "no," but what you should say is "yes."

Re:If-then-else had to be invented by rvense on Sunday December 13, 2020 @12:04PM (#25408007)
I'd say all languages work like that, not just English. Your phrasing "too ambiguous" is a little off to me. Ambiguity (in the sense of utterances having multiple possible interpretations) is the norm in natural language, and it combines with our ability to effortlessly pick the intended one based on context to make natural language work.

Even sentences that on their face are strictly propositional will, in actual situated language use, have implied meanings (a pragmatic level). The canonical example is where one person says "It's cold" (at it's core a statement of fact), after which another person closes a window, or hands them a jacket, or follows with "Let's go home, then". If you want to give an account of natural language meaning that's even remotely complete, you cannot stop at what's in the sentence at the surface, you absolutely have to look at why it's being said.

Indeed, if you think of an actual situation where someone would say "do you want to eat pizza or pasta?", I think you'd find that it does, in fact, imply that the two are exclusive in that context - say if you're at a restaurant where they only expect you to order one main course. But this is not a problem at all, it's just how language works.

(And personally, on the subject of logic and language, I'd even go as far as to say that logic is based on natural language rather than the other way around, but I think that might be tough sell to the mathematically minded.)

Re:If-then-else had to be invented by cgriswald on Sunday December 13, 2020 @12:13PM (#25408081)
>> Indeed, if you think of an actual situation where someone would say "do you want to eat pizza or pasta?", I think you'd find that it does, in fact, imply that the two are exclusive in that context

It was actually this specific question that made it clear to me that this is not the case.

In order to narrow down our takeout options, the girlfriend and I regularly ask questions like, "Do you want pizza or pasta?" meaning "Are any or all of these meal options acceptable to you?" (at which point the conversation continues with maybe us listing a few restaurants which offering one or both options.) This is the same exact phrase, but from context it is inclusive or.

>> - say if you're at a restaurant where they only expect you to order one main course.

Indeed, if the question was something like "Would you like soup or salad?" where, from context, the choice is binary and exclusive.

Re:If-then-else had to be invented by potiuper on Sunday December 13, 2020 @11:53AM (#25407905)
What is wrong with a yes response to "do you want to eat pizza or pasta?" with yes implying that one would be willing to eat either rather than requiring an exclusive preference that could be asked with "either" before pizza? Similarly with the boy or girl question, "no" may be stillborn.
Re:If-then-else had to be invented by combatentropy on Sunday December 13, 2020 @06:10PM (#25411416)
> What is wrong with a yes response to "do you want to eat pizza or pasta?"

It doesn't answer the question. The questioner is asking for your help in making a decision. If you are completely neutral about the two, then most people answer with the phrase, "Either one is fine". Saying just "yes" sounds like you misunderstood the question --- unless you say it with a wry smile, showing that you mean to be funny in your answer.

(I suppose occasionally someone could ask the question with a different inflection, with the last word at a higher pitch, meaning, "Are either of these fine with you?" rather than, "Please pick one.")

> Similarly with the boy or girl question, "no" may be stillborn.

The sex is set at conception.

Re:If-then-else had to be invented by tsimionescu on Monday December 14, 2020 @06:31AM (#25415844)
Completely off topic, but this is a pet peeve of mine:

> > Similarly with the boy or girl question, "no" may be stillborn.

> The sex is set at conception.

Not necessarily - at conception, the cells could be XX, XY, but also XXY (not to mention, they could be X- or -Y). After conception, chymerism could occur, where XX and XY twins become conjoined and a single fetus develops having both XX and XY chromosomes in different parts of the body - the sex will mostly be determined by which DNA is used when forming the gonads. It could also end up developing both kinds of gonads. But even if the fetus develops testicles, there is a chance that it has some kind of testosterone resistance and ends up with a completely female phenotype. Of course, there is also a possibility that no gonads are developed. This is all staying well in the realm of biological sex, and disregarding other hormonal complications that could happen based on what the mother is doing and her health, and disregarding any morphological abnormalities that could cause surface-level confusion between biologically male and female sexual organs.

Re:If-then-else had to be invented by combatentropy on Monday December 14, 2020 @11:05AM (#25419080)
These are edge cases, abnormalities. Do you have this pet peeve with other topics? ("If you press the gas pedal, the car will accelerate --- unless you're out of gas, the fuel line is broken . . . ")
Re:If-then-else had to be invented by u801e on Sunday December 13, 2020 @11:25AM (#25407647)
One way to make the or inclusive is to use the construct and/or.
Re:If-then-else had to be invented by nmg on Sunday December 13, 2020 @04:34PM (#25410519)
This may be why interrogative programming never caught on.