Blocks are sequences of SALIERI statements seperated by semicolons ";" and enclosed by single quotes `...´. (Note, that the closing single quotes "´" and "'" can be used synonymously.) Blocks are the most simple functional objects, they are used within control structures like loops and conditionals and for function and macro bodies.
A block is really a special function which has generally no parameters and no local workspace and it is always evaluated within the context where it was declared. Thus, object names appearing in a block are always treated as if they were found just outside the declaration of the block (see example below).
There are two different types of blocks: statement blocks and expression blocks. Statement blocks contain only statements; when evaluated, these statements are executed, but there will be no result value. Examples for statement blocks are loop bodies and the bodies of procedural functions (i.e., functions which don't return a value). Expression blocks, on the other hand, end with an expression or a return statement, which, when evaluated, determines the result value of the block. Examples for these are loop conditions such as `i<10' or the bodies of functions which return a value.
Blocks are treated as ordinary objects of type "function", as such they can be created, copied, deleted, and passed as function parameters. Block objects are executed using the predefined function apply (see example below).
A special case of a statement block is `', the empty block. When executed, it has no effect (and of course returns no value).
function (Object Type).
> b := `x:=3'
> x := 1;
> be := `x>=3'
> if(be, `x:=0', b);
> f := FUNC(2, `if(`apply($1)',`apply($2)')');
> f(`x<1', `x:=1; write("x=",x)')
> f2 := FUNC(1, `if(`apply($1)',`x:=2; write("x=", x)')');
[Contents] · [Home] · [Mail]
© sic!systems, page frame designed by hh; this page has been automatically generated from the SALIERI Documentation Database.
See also: FUNC, MACRO, apply, return, function (Object Type).