perm filename MACLIE.WRU[DOC,AIL] blob sn#113942 filedate 1974-08-05 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00003 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	NOVEMBER 28,1973 
C00006 00003	January 22,1974 
C00008 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 body of MAC, A 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.  

January 22,1974 

1.  In order to take advantage of the nestable character feature in the 
parameters to a macro call, one must be in REQUIRE DELIMITERS mode.  
Otherwise scanning will break upon seeing a comma or a right parenthesis.  

	BEGIN 
		DEFINE FOO(A) = "A"; 
		INTEGER ARRAY ABC[1:10,1:10]; 
		FOO(ABC[1,2])←3; 
		END; 

	This is identical to:

	BEGIN 
		INTEGER ARRAY ABC[1:10,1:10]; 
		ABC[1←3;  comment this is an illegal statement; 
		END; 
	
However, if the original program had included a REQUIRE DELIMITERS statement 
prior to the macro call, as below, then the desired effect would have resulted - 
i.e. ABC[1,2]←3 .  

	BEGIN 
		REQUIRE "{}%$" DELIMITERS; 
		DEFINE FOO(A) = {A}; 
		INTEGER ARRAY ABC[1:10,1:10]; 
		FOO(ABC[1,2])←3; 
		END;