: UNTIL ( -- ) ?COMPILING
COMADMIN@ BEGINADMIN ?PAIRS
POSTPONE JOF
HERE 0 ,
OFFSET! ; IMMEDIATE
Remember that
IF and
BEGIN leave a message for
THEN and
UNTIL.
3. Unconditional branches
IF...THEN and
BEGIN...UNTIL have counterparts,
AHEAD...THEN and
BEGIN...AGAIN, that use unconditional jumps.
These words don't consume a flag, don't do tests and, at first blush,
seem to be perfectly useless:
AHEAD ??? THEN ...
BEGIN ... AGAIN ???
AHEAD always jumps forward to
THEN and
AGAIN always
jumps to
BEGIN.
Why the unreachable code
??? after
AHEAD and after
AGAIN ?
These structures only make sense when used in an unstructured way
with other control structures.
... IF ... ELSE ... THEN ... can be seen as
... IF ... AHEAD THEN ... THEN where the first
THEN matches
IF and the second
THEN matches
AHEAD.
In other words: wrongly nested.
This can be made 'whole' again with a trick,
if desired, when, exactly between
AHEAD and
THEN,
the two compiler administration packets are switched.
A standard word to do this exists:
1 CS-ROLL
: ELSE (--)
POSTPONE AHEAD 1 CS-ROLL
POSTPONE THEN ; IMMEDIATE
The same trick can be used for
AGAIN:
... BEGIN ... IF ... AGAIN THEN ... turns into
... BEGIN ... IF ... AGAIN? ... with
: AGAIN? ( -- )
POSTPONE AGAIN 1 CS-ROLL
POSTPONE THEN ; IMMEDIATE
However, a different solution for this specific problem exists.
We'll tell you about it next time.