The 'if/eif/else' prototype is:
if condition1 instructions1 [eif condition2 instructions2] [eif condition3 instructions3] ... [else instruction4]
An example:
var Int i if i=0 console "i is zero" eol eif i=1 console "i is is one" eol else console "i is plural" eol
Please, notice that only one of the cases will be executed. Moreover, if the condition is a constant value that can be evaluated at compile time, only the useful part will be compiled ; it means that the Pliant 'if' operator may be used to replace the #ifdef and #if operators of the C preprocessor.
The 'while' prototype is:
while condition instructions
var Int i := 5 while i>1 console "i = " i eol i := i\2
The 'for' prototype is:
for variable start limit [step step] instructions
for (var Int i) 0 5 console "i = " i eol
The 'shunt' prototype is:
shunt condition1 result1 [condition2 result2] ... if_none_was_satisfyed_result
function abs x -> y arg Int x y y := shunt x>=0 x -x
Note for C users: 'shunt' is equivalent of ? :
The 'part' prototype is:
part name body
leave name
restart name
The meaning is execute the body, but while executing the body, 'leave' enables you to jump at the end of the body, and 'restart' enables you to jump at the beginning of the body.
function search_ab s -> position arg Str s ; arg Int position part search_a for (var Int i) 0 s:len-1 if s:i="a" leave search_a return -1 part search_b for (var Int j) i s:len-1 if s:j="b" leave search_b return -1 position := j console (search_ab "0123a56b89") eol