Special Operator go

Syntax:

7.8.5 17

go tag

Arguments and Values:

tag—a go tag. a \term{symbol} or an \term{integer}.

Description:

7.8.5 16go transfers control to the point in the body of an enclosing tagbody form labeled by a tag eql to tag. !!! Barmar: Which TAGBODY forms was the first sentence talking about?? GO only examines lexically containing forms.If there is no such tag in the body, the bodies of lexically containing tagbody forms (if any) are examined as well. If several tags are eql to tag, control is transferred to whichever matching tag is contained in the innermost tagbody form that contains the go. The consequences are undefined if there is no matching tag lexically visible to the point of the go.

This is all said in a concept section now. --sjl 7 Mar 92 \issue{EXIT-EXTENT:MINIMAL} When a transfer of control is initiated by \specref{go}, the following events occur in order to accomplish the transfer of control. Note that for \specref{go}, the \term{exit point} is the \term{form} within the \specref{tagbody} that is being executed at the time the \specref{go} is performed. \beginlist \itemitem{1.} Intervening \term{exit points} are ``abandoned'' (\ie their \term{extent} ends and it is no longer valid to attempt to transfer control through them). \itemitem{2.} The cleanup clauses of any intervening \specref{unwind-protect} clauses are evaluated. \itemitem{3.} Intervening dynamic \term{bindings} of \declref{special} variables and \term{catch tags} are undone. \itemitem{4.} The \term{extent} of the \term{exit point} being invoked ends, and control is passed to the target. \endlist The extent of an exit being ``abandoned'' because it is being passed over ends as soon as the transfer of control is initiated. That is, event 1 occurs at the beginning of the initiation of the transfer of control. The consequences are undefined if an attempt is made to transfer control to an \term{exit point} whose \term{dynamic extent} has ended. Moon had me add the part about "interleaved" -kmp 13-Feb-92 Events 2 and 3 are actually performed interleaved, in the order corresponding to the reverse order in which they were established. The effect of this is that the cleanup clauses of an \specref{unwind-protect} sees the same dynamic \term{bindings} of variables and \term{catch tags} as were visible when the \specref{unwind-protect} was entered. Event 4 occurs at the end of the transfer of control. \endissue{EXIT-EXTENT:MINIMAL}

The transfer of control initiated by go is performed as described in Section 5.2 (Transfer of Control to an Exit Point).

Examples:

 (tagbody
   (setq val 2)
   (go lp)
   (incf val 3)
   lp (incf val 4)) → NIL
 val → 6 

The following is in error because there is a normal exit of the tagbody before the go is executed.

 (let ((a nil)) 
   (tagbody t (setq a #'(lambda () (go t))))
   (funcall a))

The following is in error because the tagbody is passed over before the go form is executed.

 (funcall (block nil
            (tagbody a (return #'(lambda () (go a))))))

Affected By:

None.

Exceptional Situations:

None.

See Also:

tagbody

Notes:

None.