OTPCL flow control commands
Following Tcl's tradition, OTPCL's flow control "structures" are essentially just commands that take strings and evaluate them in various ways. Said commands' definitions live in this here module.'if'/2 | Evaluates the second argument if the first is "truthy". |
for/2 | Repeatedly evals the given clause with values from a list. |
truthy/1 | See truthy/2 . |
truthy/2 | Determine if a value is "truthy". |
unless/2 | Inverse of if . |
while/2 | Repeatedly evals the second clause for as long as the first clause evaluates to a truthy value. |
'if'(X1, State) -> any()
Evaluates the second argument if the first is "truthy". If there's a third argument, it'll be evaluated if the first is not "truthy".
for(X1, State) -> any()
Repeatedly evals the given clause with values from a list. Synopsis:
for each in $list { mangle $each }
each
here could be literally any variable name. Return value will be the
value returned by the last invocation/evaluation of the body clause.
truthy(T) -> any()
See truthy/2
.
truthy(X1, State) -> any()
Determine if a value is "truthy". All values are deemed to be "truthy" (that is: will cause a control command's predicate to be treated as "true" unless they are in any of the following categories:
0
or float 0.0
)false
or error
error
unless(X1, State) -> any()
Inverse of if
. Does not accept a third clause, thus disallowing
"unless/else" constructs (if you want those, go back to Perl -- and I say this
as someone who loves Perl).
while(X1, State) -> any()
Repeatedly evals the second clause for as long as the first clause
evaluates to a truthy value. Word of caution: OTPCL currently lacks the
concept of a break
statement, so if you ain't careful here you'll end up
with an infinitely-looping OTPCL interpreter (TODO: fix that).
Generated by EDoc