GENERATE/PREV.gifGENERATE/NEXT.gif

Parameters

The parameters to a function act exactly as though they were local variables that have been declared at the head of the function body, and that are initialized with the arguments given by the caller. They have a scope that extends to the end of the body <expr>. They can be assigned to and hidden by nested local variables with the same name, as can other local variables. Assigning to a parameter variable has no effect on the caller's context, it is an entirely local action.

Keyword parameters can be given default values in the function definition, implicitly making them optional to the caller, as in the starfield function example in the Function Definition topic. If the caller does not supply one of these keyword arguments, it is initialized to the default value upon function entry. The default values are specified after the ':' colon.

If a keyword parameter is defined with no default value and is not supplied by the caller, it is initialized to the special value unsupplied. You can check for this value in the body of your function and handle missing required keyword argument errors accordingly.

Example:

fn foo a b: c: d: =

(

if c == unsuppplied then print "Where's the c: argument??"

...

)