Live data from Hacker News

If-then-else had to be invented

github.com

231–240 of 255 posts

Re: If-then-else had to be invented

#232

Earlier quoted context omitted.

I would say that in every case there is a set of things (maybe with a single member) and a set of predicates (maybe with a single member), a mapping from the things to the predicates, and every mapping produces a true proposition. "Women and children were present" isn't saying the intersection of the women and children were present but that the things were women and children and they all were present. The rest of the…

The meaning of “and” in natural language predates the meaning of “and” used in logics and set theories. I’m not convinced that all semantics of “and” can be derived from set operations. 1) not every clause is a predicate and applying logical operators to a non-predicate makes very little sense to me. 2) I don’t see how ordering, time, and causation can be inferred, if you treat each clause as a predicate. “I punched…

> The meaning of “and” in natural language predates the meaning of “and” used in logics and set theories

Yes and it's usually very hard to summarize what words can mean in different contexts, therefore it's usually harder to learn natural languages than programming languages. For example, in a programming language "while you're out, pick up some milk" would be an infinite loop. I think this is why Alexa, Google Assistant, Siri and many more are only finding usage for the simplest of tasks.

Re: If-then-else had to be invented

#233
post #54
post #41

Earlier quoted context omitted.

I think for these purposes, “else” is different from the “or else” construction. As in: “Read thee the article, else thou shall suffer great ridicule in the comments.”

"thee" is the dative (and later accusative) inflected form of "thou", the second person singular pronoun. In your sentence above "Read" is the imperative form of the verb. The subject is elided since it's implicitly second person (singular or plural) (as imperative is used to give orders to people you're talking to) and if it wasn't elided it would have been in nominative case. Middle english had an ending -(e)th to…

This is fantastic

Re: If-then-else had to be invented

#234
post #41

Earlier quoted context omitted.

I think for these purposes, “else” is different from the “or else” construction. As in: “Read thee the article, else thou shall suffer great ridicule in the comments.”

(At least a couple of wrong words there: “thee” should be “thou”, and “shall” should be “shalt”. Also I reckon “thou shalt” reads much better as “shalt thou” in this style, though either is acceptable. Final proposed form: “Read thou the article, else shalt thou suffer great ridicule in the comments.” The overall style of the sentence is still rather off for the era, but it’ll do.)

“The best way to get an answer in the internet is not to ask a question, but to post something incorrect.” - Thomas Jefferson

Re: If-then-else had to be invented

#235

I remember there was a paper that tried to compare natural language usage of common programming language keywords to see if they may come up with other constructs to create a programming language that is easier to learn as your first one. There were a few interesting observations. The one that stuck with me the most is that 'and' is most commonly used with almost the opposite sense in natural language vs programming:…

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.

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

#236
post #9

Earlier quoted context omitted.

Unless you compile your program with movfuscator: https://github.com/xoreaxeaxeax/movfuscator Or you decide to execute code on The Fungus: https://www.bedroomlan.org/hardware/fungus I also recall reading a paper that got into implementing a GC on silicon for a graph rewriting based architecture WebAssembly is if/else blocks. There's a potential future where it gets implemented directly as a CPU ISA (albeit it'd likel…

> I also recall reading a paper that got into implementing a GC on silicon for a graph rewriting based architecture Maybe this one: https://github.com/tommythorn/Reduceron

That's the one. Gets me breaking out in a solid minute of laughter imagining C code that thinks its "close to the metal" being compiled to that

Re: If-then-else had to be invented

#237

Fun fact: English isn't my native language and I learned programming before becoming fluent in English. I believed for a long time that 'else' was just a shorter alternative for 'otherwise'. I used to say things like "I'll have apple juice if you've got some, else I'll have orange juice."

This is a totally correct usage, it just makes you sound like a romantic poet or a 19th century orator.

Re: If-then-else had to be invented

#238

Earlier quoted context omitted.

> 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…

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 diffe…

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

#239
post #216

Referring to the three-way “FORTRAN” syntax, you say, “The three-way "if" was more powerful than just checking for a negative, but was probably more confusing,” this is not right. As a 15-year-old at Stuyvesant, in 1966, learning FORTRAN 4, I assure you it was the most natural thing in the world. Especially instructive was the fact that usually two of the target statement numbers would be the same. FORTRAN 4 didn’t h…

Thanks. It has been cited as confusing in sources like The Elements of Programming Style, but I can appreciate that it may feel natural to some people, and there are certainly cases like strcmp() where a three-way distinction is necessary, and current languages lack a good way to talk about it.

Re: If-then-else had to be invented

#240

I would love to read something similar about a "for" loop. "if/else" always sounded natural to me, but a "for" to mean a loop never did.

For is also from Algol, replacing "do" from Fortran. I agree it would be interesting to know why the word was chosen, but I think it comes from the mathematical "for all x in Y, x > 5" or whatever other assertion is being made.
Post reply on HN