HELP GOTO                                           John Gibson March 86

A goto statement in POP-11 transfers control to the instruction labelled
by the following word. For example:

    define laugh();
        l: ppr("ho");
        goto l
    enddefine;

    laugh();
    ho ho ho ho ho ho ho ho ho ........

Here 'l:' labels the following instruction and 'goto L' transfers
control to the labelled point.  The label may be either a local label
(somewhere in the current procedure) or a non-local one (somewhere in a
lexically-enclosing procedure).  A non-local GOTO is like doing an
EXITTO to the target procedure (see HELP *EXITTO), followed by a local
jump to the label.

The use of labels is hardly ever necessary (see HELP *LOOPS).  If
you have to use labels to write a program this may be because you don't
really understand the problem the program is solving, or you haven't
thought hard enough about how to express the program clearly.
Occasionally GOTO is useful, e.g. as a way of representing a 'finite
state machine', but even then there may be better ways of doing it.

Non-local GOTO is sometimes useful for terminating a search deep in
recursion. For details see the section of REF * VMCODE describing the
implementation of non-local jumps.

See also HELP

    *LABELS       - representation of labels in POP-11
    *CONDITIONALS - summary of conditional statements in POP-11
    *GO_ON        - jumping to a label according to the value of an integer

See REF * VMCODE/Labels for more on labels and jumps
