defglobalfun
defglobalfun(s_funcName(l_formalArglist)g_expr1... ) =>s_funcName
Description
Defines a global function with the name and formal argument list you specify.
The functions that you define using defglobalfun are defined within a lexical scope, but are globally accessible.
For defglobalfun there must be white space between s_funcName and the open parenthesis. Expressions within the function can reference any variable on the formal argument list or any global variable defined outside the function. If necessary, local variables can be declared using the let function.
Arguments
|
Expression or expressions to be evaluated when s_funcName is called. |
Value Returned
Examples
Define two global functions, test_set and test_get using defglobalfun and that reference a lexical variable secret_val:
toplevel 'ils
ILS-<2> (let ((secret_val 1))
(defglobalfun test_set (x) secret_val = x)
(globalProc test_get() secret_val)
)
ILS-<2> test_get()
=> 1
ILS-<2> test_set(2)
=> 2
Related Topics
Function and Program Structure
Return to top