[Contents] · [Home] · [Mail]

SALIERI Language - FUNC

Type:
FUNC: integer x expr_block -> function

Call syntax:
FUNC(nrOfParams, funcBody)

Description:
Returns the nrOfParams-place function which is defined by block funcBody. Within the function body the actual parameters are accessed as 1, 2, ... . Parameters are passed call-by-value, i.e., they are represented by local variables inside the function body. Functions with a variable number of parameters can be realized by specifying nrOfParams as -1. In this case, $1 represents a list containing all actual parameters. Variables that are defined / modified in funcBody are local; there is no way to modify global variables within a function body. However, global variables can be accessed in the usual manner (by their name), if no local variable with an identical name exists. Local variables exist only during the execution of a function body and they are not persistent, i.e., their value does not persist between two calls of the same function. Execution of a function body can be prematurely ended by the functions return or abort.

Attention!

Example:
> f := FUNC(2, `return(1+2)´)
> f("xy,z")
Result = "xyz"
> f(1,2)
Result = 3
> x := 3;
> f := FUNC(2, `x := 1; write("x=",x)´)
> f(0)
x=0
x
Result = 3

See also: MACRO, return.


[Contents] · [Home] · [Mail]
© sic!systems, page frame designed by hh; this page has been automatically generated from the SALIERI Documentation Database.