DEFINE - define a new user macro.

Usage:

$define(name(formals), body)

Where:

name
is the name of the macro being defined.
(formals)
is a list containing the names of formal parameters for the macro. The parameter names are separated by commas. If there are no paramenters, the enclosing parentheses are omitted.
body
is the body of the macro. It must be well-balanced with respect to parentheses. References to the formal arguments within the body are coded as "$arg" where "arg" is the name of the parameter.

Description:

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.

Examples:

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.