nprocedure
nprocedure(s_funcName(s_formalArgument)g_expr1... ) =>s_funcName
Description
(SKILL mode only) Defines an nlambda function with a function name and a single formal argument. This is a syntax form that is not supported in SKILL++ mode.
The body of the procedure is a list of expressions to be evaluated one after another. The value of the last expression evaluated is returned as the value of the function. There must be no white space separating the s_funcName and the open parenthesis of the list containing s_formalArgument.
An nlambda function defined by nprocedure differs from a lambda function defined by procedure in that an nlambda function does not evaluate its arguments; it binds the whole argument list to its single formal argument. lambda functions, on the other hand, evaluate each argument in the argument list and bind them one by one to each formal argument on the formal argument list. It is recommended that procedure be used over nprocedure whenever possible, in part because procedure is faster and also offers better type checking.
In general, it is preferable to use lambda instead of nlambda because lambda is more efficient.
Arguments
|
SKILL expressions to be evaluated when the function is called. |
Value Returned
Examples
procedure( printarg(x) println(x))
=> printarg
nprocedure( nprintarg(x) println(x))
=> nprintarg
Calls alambdafunction. Prints the value 20.printlnreturnsnil.y = 10
=> 10
printarg(y * 2)
20
=> nil
Calls an nlambda function. Prints a list of the unevaluated arguments. println returns nil.
nprintarg(y * 2)
((y * 2))
=> nil
Related Topics
Function and Program Structure
Return to top