[Contents] · [Home] · [Mail]

SALIERI Language - Macros

Macros are objects of type function which have no local workspace but are treated exactly like user-defined functions in every other respect.

Macros are created using the constructor MACRO and can be assigned, copied, modified or deleted just as objects of any other type in SALIERI.

Macros can be executed by using either the standard function call syntax (as for built-in SALIERI function, cf. Section User-defined Functions) or the apply function. Function definitions can be recursive, i.e., a function can call itself from within its function body. However, when working with recursive functions, one should be carefull to avoid too deep or endless recursions which might lead to system crashes.

Different from functions, macros don't have a local workspace, i.e., within macro bodies one can create, modify or delete objects in the global workspace. If a macro requires the use of local objects, these have to be named $id, where id is any valid object name. Macro parameters are generally evaluated and stored in local objects $1, $2, etc. before a macro body is executed.

Example:
> m := MACRO(1, `res := $1+$1; write(res)')
> m("abc")
abcabc
> res
abcabc

See also: User-defined Functions & Macros, function (Object Type), MACRO, apply, return.


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