MACROS - macros in MAP.

Description:

MAP supports a limited string macro facility. The user may define macros by associating a string of characters with a name. This string of characters is known as the "body" of the macro; it must be well-balanced with respect to parentheses. The macro may be "called" in a source program at any point after the macro is defined, with the effect that the call is replaced by the body. The body itself may call other macros, including itself.

A macro may be redefined at any time. Macros may also have formal parameters which are replaced at macro call time by actual parameters.

A macro is called by prefixing a "$" to the name and supplying a (possibly empty) list of arguments. Each argument consists of a string of characters, (well-balanced with respect to parentheses) followed by a comma or a right parenthesis. Unlike the body of the macro, actual arguments to user-defined macros may not contain references to formal parameters or other macros. This severely restricts the computational power of the macros, but means that the order of argument evaluation does not affect the value of the macro. Missing arguments are replaced by the null string, and extra arguments are ignored. A macro call must always be be followed by a matched pair of parentheses, even if there are no arguments. Note that this is inconsistent with the declaration syntax and the Pascal syntax. (It can be argued that it is much more readable.)

While macros may be defined to have a null body, calling an undefined macro is an error.

A macro call cannot occur inside a literal string or comment.

System Macros:

In addition to user-defined macros, MAP supplies five predeclared macros that perform various functions. Although they are not macros in the strict sense, they are invoked using the standard macro call syntax and may be redefined like macros. The predefined macros are:

codeif     Conditionally compile some code.
define     Define a user macro.
include    Include a source file for processing.
options    Set some MAP options.
seqnum     Generate a new integer.

Copyright © 1996, Thinkage Ltd.