Ah, 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?
There's a language where THEN basically means ENDIF... Forth, if memory serves me right?
I think the tactic strategy to achieve this is to confine conditional branches in a few well chosen words.
For instance if you have a word SORT that sorts the top pair on the stack, which has to have a branch:
: SORT 2DUP < IF SWAP THEN ;
then you can build "if-less" MIN, MAX and ABS: : MIN SORT NIP ;
: MAX SORT DROP ;
: ABS 0 SORT SWAP - ;IF you go to the store get some butter THEN come right back.
So THEN is where the program continues on a false condition. Typically Forth. It uses an alternative way of looking at things.
[0] https://gforth.org/manual/Selection.html
See also the StackOverflow thread on this topic: https://stackoverflow.com/q/12539634/
: /CHECK DUP 0= IF ." invalid " DROP ELSE / THEN ;
https://www.forth.com/starting-forth/4-conditional-if-then-s...