mprocedure
mprocedure(s_macroName(s_formalArgument)g_expr1... ) =>s_funcName
Description
Defines a macro with the given name that takes a single formal argument. This is a syntax form.
The body of the macro is a list of expressions to be evaluated one after another. The value of the last expression evaluated is considered the result of macro expansion and is evaluated again to get the value of the macro call.
When a macro is called, s_formalArgument is bound to the entire macro call form, that is, a list with the name of the macro as its first element followed by the unevaluated arguments to the macro call.
Macros in SKILL are completely general in that a macro body can call any other function to build an expression that is to be evaluated again.
A macro call within a function definition is expanded only once, when the function is compiled. For this reason, be cautious when defining macros. sure they are purely functional, that is, side-effects free. You can use
expandMacro to verify the correct behavior of a macro definition.Arguments
Value Returned
Examples
mprocedure( whenNot(callForm)
‘(if !,(cadr callForm) then ,@(cddr callForm)))
=> whenNot
expandMacro( '(whenNot x>y z=f(y) x*z))
=> if(!(x>y) then (z=f(y)) (x*z))
whenNot(1>2 "Good")
=> "Good"
Related Topics
Function and Program Structure
Return to top