Think of it as: " IF , what if, do it, ELSE do it ... and THEN continue with ..."
Or itβs even better to use quotes (as in Factor , RetroForth , ...), in which case it is completely postfix without special compile-time words; just regular words that accept addresses from the stack: [ do this ] [ do that ] if or [ do this ] when or [ do that ] unless . I personally prefer that.
Beyond RE: Quotes
Here's how quotes are compiled in RetroForth . In my own Forth (which compiles to my own virtual machine) I just added a QUOTE statement that pops the next address onto the stack and jumps through n-bytes. It is expected that n-bytes will be completed with the RETURN command, and the words IF , when , unless will use the predicate along with the address (s) left by previous quotes; calling if necessary. Very simple, and quotes usually open the door to all kinds of beautiful abstractions from the thought of the stack .
source share