perm filename MACLIE.WRU[DOC,AIL]1 blob
sn#075284 filedate 1973-11-30 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00002 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 NOVEMBER 28,1973
C00006 ENDMK
C⊗;
NOVEMBER 28,1973
The following is a set of hints and aids in debugging programs with macros.
Unless iotherwise stated array brackets are the macro body delimiters.
If you encounter other strange quirks, do not hesitate to inform HJS
about them so others will bwnefit from your experience.
1. IFC and friends will not trigger at the point of macro definition, in
a macro actual parameter list, or inside a string constant.
DEFINE FOO = [IFC A THENC B ELSEC D ENDC];
which is not the same as
DEFINE FOO = IFC A THENC [B] ELSEC [D] ENDC;
DEFINE BAZ(A) = [OUTSTR("A");];
BAZ(IFC B THENC C ELSEC D ENDC)
will result in the following string typed on your terminal:
IFC B THENC C ELSEC D ENDC
STRING A;
A←"IFC WILL NOT TRIGGER HERE";
2. Macros will not be expanded in strings, but macro formal parameters
will be expanded when they occur in strings within macro bodies as seen
in the second example of 1. above.
DEFINE FOO = [BAZ];
OUTSTR("FOO");
which will type out the string FOO on your terminal rather than BAZ.
3. Caution should be employed when using letters (specifically ⊂⊃) as
delimiters. This may lead to problems when defining macros within macros.
DEFINE MAC(A) "⊂⊃" = ⊂REDEFINE FOO =⊂A⊃;⊃;
A inside the macro bdy of MAC will not be recognized as a formal
since the scanner has scanned ⊂A⊃ as an identifier by virtue of ⊂⊃
being internally represented as letters so that some of YOU could
define them to mean BEGIN and END respectively (also ⊂ as COMMENT).
More justification for this feature is seen by the following example:
DEFINE MAC(ABC) "AC" = A V←ABC; C;
We want ABC in the text to be the parameter and not B if we were to
ignore the macro delimiters.
4. When scanning lists of actual parameters, macros are not expanded.
DEFINE FOO = [A,B];
MAC(FOO) will not have the result MAC(A,B) however,
DEFINE FOO = [(A,B)]
followed by MAC FOO will have the same effect as MAC(A,B)
The same reasoning holds for parameter lists to FORLC.
DEFINE FOO = [A,B,C];
FORLC I = (FOO) DOC [OUTSTR("I");] ENDC
will result in FOO typed out on your terminal.
DEFINE FOO = [(A,B,C)];
FORLC I = FOO DOC [OUTSTR("I");] ENDC
will have the desired result ABC typed out on your terminal.