Hacker News new | ask | show | jobs
by RodgerTheGreat 5444 days ago
Forth can be used to create 'if' statements from scratch, too. Many Forth implementations start up by loading a set of definitions for things like comments, conditionals and flow control.

  : IF    COMPILE 0BRANCH HERE 0 ,                 ; IMMEDIATE
  : ELSE  COMPILE BRANCH HERE SWAP 0 , HERE SWAP ! ; IMMEDIATE
  : THEN  HERE SWAP !                              ; IMMEDIATE