
You can sometimes achieve the very same effect by using the word 'EXIT' on a strategic place. We've already encountered 'EXIT'. It is the actual word that is compiled by ';'.
What you didn't know is that you can compile an 'EXIT' without using a ';'. And it does the very same thing: it pops the return address from the Return Stack and jumps to it. Let's take a look at our slightly modified previous example:
: soup ." soup " ; ( r1 r2)
: dessert ." dessert " ; ( r1 r6)
: chicken ." chicken " ; ( r1 r3 r4)
: rice ." rice " ; ( is never reached)
: entree chicken exit rice ; ( r1 r3)
: dinner soup entree dessert ; ( r1)
dinner cr ( --)
After "CHICKEN" has been executed by "ENTREE", an 'EXIT' is encoun- tered. 'EXIT' works just like ';', so 4tH thinks the colon-definition has come to an end and jumps back to "DINNER". It never comes to calling "RICE", so the output is:
soup chicken dessert
'EXIT' is mostly used in combination with some kind of branching like IF..ELSE..THEN. Compare it with 'LEAVE' that leaves a DO..LOOP early.
But now for the big question: what is the difference between 'EXIT' and ';'? Both compile an 'EXIT', but they are not aliases. 4tH will try to match every ';' with a ':'. If it doesn't succeed, it will issue an error message. This matching is not performed by 'EXIT'.