If/else is just as made up as for loops - it’s all if/goto underneath.
If-then-else had to be invented
21–30 of 255 posts
Re: If-then-else had to be invented
#22Earlier quoted context omitted.
Having taught programming to novices a little, I believe “if not” is clearer than “else”. Imagining “not” being prepended to the original conditional expression would be natural, especially in languages with “not X” construct (like Python), and it’s easy to forget that “else” is in fact archaic to non-programmer ears, slightly and possibly needlessly raising the barrier. if (X) { doY(); } if not /* X is implied */ {…
What if there were 3 cases though? "Else" should exclude both of the preceding cases, but the phrasing of "If not" seems to imply it would only exclude the previous case
A point could be made for restricting ifs to 1 or 2 clauses and delegating more complex conditions to switch/case, but that is arguably even more far out there (and in case of Python it actually doesn’t have the switch operator). Also, “if not X {…} if not {…}” would be confusing but possible.
I guess I should leave language design to the better-equipped for the time being.
Re: If-then-else had to be invented
#23You can use "else" that way in ordinary speech. "If this then do that else do the other thing" is perfectly legitimate English, just a bit archaic.
Methinks it's rather ordinary.
Re: If-then-else had to be invented
#24[0] https://en.wikipedia.org/wiki/Haskell_Curry [1] http://athena.union.edu/~hemmendd/Courses/cs80/eniac-women.p...
Re: If-then-else had to be invented
#25If/else is just as made up as for loops - it’s all if/goto underneath.
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…
Not that, but still interesting: the Intel iAPX 432[0] was a (failed) processor from 1981 designed with high level languages in mind (specifically Ada). It supported bit-level aligned, variable length instruction, but also a built in GC and type tagging system.
Re: If-then-else had to be invented
#26Earlier quoted context omitted.
Wiktionary has a usage example from 1903, clearly before modern computers but not too ancient. > 1903, Jack London, The Call of the Wild, Grosset & Dunlap, page 44: > […] and his first experience taught him an unforgetable lesson. It is true, it was a vicarious experience, else he would not have lived to profit by it. As an aside there is at least one common word which does seem to have been invented by the software…
> “... one common word which does seem to have been invented by the software industry: "access" as a verb” Really? That’s surprising because the French and Spanish equivalent verb (accéder / acceder) is common and has multiple meanings such as “reaching a peak”. I would have imagined this word transferred over in the Norman days.
Re: If-then-else had to be invented
#27You can use "else" that way in ordinary speech. "If this then do that else do the other thing" is perfectly legitimate English, just a bit archaic.
Examples: "Go to college or else work for your uncle"
Turn this into boolean form: "If you go to college then or else you will work for your uncle"
But the "or" makes the meaning ambiguous: "If it rains then I will work inside or else I will work outside."
It is not clear if this means you will work outside if and only if it is not raining? Maybe working outside is another option if it rains.
Otherwise is far more clear. "If it rains then I will work inside otherwise I will work outside."
Removing the "or" completely makes the statements unambiguous archaic English: "If you go to college then else you will work for your uncle" "If it rains then I will work inside else I will work outside."
FWIW - I am very glad they chose else over otherwise...
Re: If-then-else had to be invented
#28Re: If-then-else had to be invented
#29If/else is just as made up as for loops - it’s all if/goto underneath.
'if x then y else z' becomes 'xy + (1-x)z', or 'x*(y-z)+z'
Re: If-then-else had to be invented
#30You can use "else" that way in ordinary speech. "If this then do that else do the other thing" is perfectly legitimate English, just a bit archaic.
It does not even register as “archaic” to me. Methinks it's rather ordinary.