If-then-else had to be invented
github.com
If-then-else had to be invented
1–10 of 255 posts
Re: If-then-else had to be invented
#2I started with BBC Basic II (on the Model B) which had IF..THEN but it was just one line and there was no ELSE. So if you wanted to make a 'block' you had to call a different PROC (thankfully there were PROCedures so you could avoid GOTO)
As such when I was introduced to ELSE and ENDIF with BBC BASIC V on the Archimedes it seemed like very welcome syntactic sugar - it let you do the same stuff but in a tidier way
Re: If-then-else had to be invented
#3Re: If-then-else had to be invented
#4> The Tenth Edition rc does not have the else keyword. Instead, if is
> optionally followed by an if not clause which is executed if the pre-
> ceding if test does not succeed.
which i found pretty interesting
Re: If-then-else had to be invented
#5There's a language where THEN basically means ENDIF... Forth, if memory serves me right?
Re: If-then-else had to be invented
#6Re: If-then-else had to be invented
#7Ah, interesting, I wish the title had been prefixed with "What if ". There's a language where THEN basically means ENDIF... Forth, if memory serves me right?
: /CHECK DUP 0= IF ." invalid " DROP ELSE / THEN ;
https://www.forth.com/starting-forth/4-conditional-if-then-s...Re: If-then-else had to be invented
#8You 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.
> 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 industry: "access" as a verb
Re: If-then-else had to be invented
#9If/else is just as made up as for loops - it’s all if/goto underneath.
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 likely involve some dynamic translation, but the CPU may decide to have SSA as its internal representation)
It's important to understand there's a real distinction between semantics & implementation. Otherwise you risk emulating your implementation when some new hardware comes out (say GPUs, or Quantum computers, or out of order CPUs working backwards to create something like SSA for register renaming/pipelining, or cmov)
See also the debates over C code being executed in the C abstract machine for optimizers while programmers rely on implementation of the end result. But in a language without undefined / implementation-defined behavior you won't have these ways of having the program self observe its implementation
Re: If-then-else had to be invented
#10If/else is just as made up as for loops - it’s all if/goto underneath.
BTW, it's not entirely correct that it's all if/goto. ARM has conditional execution that doesn't necessarily involve a jump, and there have been other exceptions as well.