Module otpcl_control

OTPCL flow control commands.

Description

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.

Function Index

'if'/2Evaluates the second argument if the first is "truthy".
for/2Repeatedly evals the given clause with values from a list.
truthy/1See truthy/2.
truthy/2Determine if a value is "truthy".
unless/2Inverse of if.
while/2Repeatedly evals the second clause for as long as the first clause evaluates to a truthy value.

Function Details

'if'/2

'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/2

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/1

truthy(T) -> any()

See truthy/2.

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:

unless/2

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/2

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