Next: ick_next, Previous: ick_labeledblock, Up: External Calls to C [Index]
The ick_comefrom
and ick_nextfrom
macros are,
like the other INTERCAL flow control macros (as
opposed to functions), only allowed within a function defined with
ICK_EC_FUNC_START
. They act almost exactly like the
INTERCAL statements of the same name (although note
that C statements cannot be ABSTAIN
ed FROM
even if they act the same way as INTERCAL
statements); they are written as ick_comefrom(expression);
and ick_nextfrom(expression);
respectively (note that they
must be called as statements, and cannot be used as part of an
expression). Whenever a standalone line label is encountered whose
expression evaluates to the same number as the expression inside the
ick_comefrom
or ick_nextfrom
, and that number
is at most 65535, then control will be transferred to the
ick_comefrom
or ick_nextfrom
, leaving a
NEXT
stack entry behind in the case of
ick_nextfrom
; likewise, if the end of a labeled statement,
expression or block is reached and the label has the right number. Some
caveats: the expression need not be constant, but must not have side
effects, must not be negative, and must fit into the range of an
unsigned long
in the C program (and the statement will do
nothing if the expression evaluates to a value larger than 65535). In
keeping with the best C traditions, these caveats are not checked, but
instead result in undefined behaviour if breached.
There are also versions ick_comefromif
and
ick_nextfromif
, which take a second parameter, which is a
condition that specifies whether control is actually stolen from the
target. The condition may have side effects, and is only run when the
line numbers match; it should return 0 or NULL to leave control flow
alone, or nonzero to steal control, and should be either an integral
type or a pointer type. Although side effects are allowed, the
condition must not look at or alter auto
or
register
variables in the enclosing function, not even if
they are also marked volatile
. (Global and
static
variables are fine, though.)
Next: ick_next, Previous: ick_labeledblock, Up: External Calls to C [Index]