DEFINE PROCEDURE "MINUS" [M,N]:
BLOCK 0: BEGIN
IF M < N, THEN:
QUIT BLOCK 0;
LOOP AT MOST M + t TIMES:
BLOCK t: BEGIN
IF OUTPUT + N = M, THEN:
ABORT LOOP t;
OUTPUT ¢: OUTPUT + t;
BLOCK t: END;
BLOCK 0: END.
Here we are making use of the implicit feature that OUTPUT begins at
O. If M is less than N, then the subtraction is impossible, and we simply
jump to the bottom of BLOCK 0 right away, and the answer is O. That is
what is meant by the line QUIT BLOCK O. But if M is not less than N, then
we skip over that QUIT-statement, and carry out the next command in
sequence (here, a LOOP-statement). That is how IF-statements always work
in BlooP.
So we enter LOOP t, so called because the block which it tells us to
repeat is BLOCK t. We try adding 0 to N, then 1, 2, etc., until we find a
number that gives M. At that point, we ABORT the loop we are in, meaning
we jump to the statement immediately following the END which marks the
bottom of the loop's block. In this case, that jump brings us just below
BLOCK t: END, which is to say, to the last statement of the algorithm, and
we are done. OUTPUT now contains the correct answer.
Notice that there are two distinct instructions for jumping downwards:
QUIT, and ABORT. The former pertains to blocks, the latter to loops. QUIT
BLOCK n means to jump to the last line of BLOCK n, whereas ABORT LOOP n
means to jump just below the last line of BLOCK n. This distinction only
matters when you are inside a loop and want to continue looping but to quit
the block this time around. Then you can say QUIT and the proper thing
will happen.
Also notice that the words AT MOST now precede the upper bound of
the loop, which is a warning that the loop may be aborted before the upper
bound is reached.
Automatic Chunking
Now there are two last features of BlooP to explain, both of them very
important. The first is that, once a procedure has been defined, it may be
called inside later procedure definitions. The effect of this is that once an
operation has been defined in a procedure, it is considered as simple as a primordial
step. Thus, BlooP features automatic chunking. You might compare it to
the way a good ice skater acquires new motions: not by defining them as
long sequences of primordial muscle-actions, but in terms of previously
learned motions, which were themselves learned as compounds of earlier
(^412) BlooP and FlooP and GlooP