file: job.t package: muf status: alpha
The withTags
syntax supports the goto
operator, which is primarily intended for
non-local tranfers of control from one function
to a calling function, used heavily by the
event handling system's restart
s
(see section Muq Events).
The syntax is
withTags tags do{ body }
where tags is a list of zero or more goto
target labels, and body is the code scope in which
they are to be defined and usable.
If only one tag is used, the withTag
synonym to
withTags
may be used.
Examples:
Defining a single tag x
and jumping to it:
Stack: withTag x do{ "a\n" , 'x goto "b\n" , x "c\n" , } a c Stack:
Defining three tags x, y, z
and jumping between them:
Stack: withTags x y z do{ -----> "a\n" , -----> 'y goto -----> x -----> "b\n" , -----> 'z goto -----> y -----> "c\n" , -----> 'x goto -----> z -----> "d\n" , -----> } a c b d Stack:
Finally, an example along the lines of how
withTags
and goto
are actually
intended to be used. Jumping to a tag in an
enclosing function:
Stack: : f -> arg ;----> withTags x y do{ -----> : g -> arg ;----> arg if 'x goto else 'y goto fi ;----> ; -----> arg g -----> x -----> "x\n" , -----> y -----> "y\n" , -----> } ;----> ; Stack: nil f y Stack: t f x y Stack:
Go to the first, previous, next, last section, table of contents.