$define(name(formals), body)
The system macro DEFINE is used to define a user macro. The macro name and the names of the formal parameters must be valid Pascal identifiers.
Whenever a macro definition is encountered, the body and formal parameter names are simply stored with no further processing. References to formal parameters or other macros are not checked. Errors will not be detected until the macro is called.
Define a macro "swap" as below.
$define( swap(var1, var2, temp), begin $temp :=$var1; $var1 :=$var2; $var2 :=$temp end )
The call
if a < b then $swap(a, b, i);
would expand to
if a < b then begin i:=a; a:=b; b:=i end;
Note that the semantics of this macro are different from a procedure named "swap". Besides the difference due to strong typing, consider the expansion of
$swap(i,a[i],j)
Copyright © 1996, Thinkage Ltd.