Page Numbers: Yes X: 310 Y: 10.42" First Page: 1
Margins: Top: 1.0" Bottom: 1.5"
Heading:
3-LISP WORKING GUIDE#11: Macros
———————————————————————————————————————————
Issue #11:Macros
Description:There are several open issues having to do with macros. First, should macros (especially kernel ones) expansions involve atoms, or should they be restricted to normal-form structures? This also includes read macros such as ‘↑’ and ‘\’. Second, exactly which parts of the reflective processor will be allowed to use macros? This has a bearing on the nature of the bodies of the standard continuations since macros will cause copying. Third, should macros be given their own special kind of closure? I.e., be constructed with (CCONS ’MACRO ...)?
Status:Unresolved
Last Edited:September 20, 1982 (Jim des Rivières)
———————————————————————————————————————————
In regard to macro expansions, one can see that difficulties may be encountered if atoms are used in the expansion of the ‘↑’ notation. The expression ‘↑X’ is supposed to be shorthand for ‘(UP X)’ where UP designates the level-rossing primitive. This can be achieved in one of two ways. If the notation is simply shorthand for ‘(UP X)’ then we would expect the following:
1> ↑’1
=> ’’1
1> (UP ’1)
=> ’’1
1> (DOWN ’1)
=> 1
1> (LET [[UP DOWN]] ↑’1); Changing the binding for UP changes
=> 1; what the ’↑’ notation designates.
However, there is another possible interpretation for the ‘↑’ notation — that it should use the primitive UP regardless of context. This could be achieved by making ‘↑X’ equivalent to ‘(<UP> X)’, where ‘<UP>’ notates the closure for the UP primitive. If this were the case, we would expect the following:
1> ↑’1
=> ’’1; As before.
1> (UP ’1)
=> ’’1; " "
1> (DOWN ’1)
=> 1; " "
1> (LET [[UP DOWN]] ↑’1); Changing the binding for UP has no
=> ’’1; bearing on the significance of ’↑’.
Similar concerns apply to the ‘\’ and ‘@’ notations, which use DOWN and PCONS/RCONS, respectively. Moreover, it also applies to regular macros. Compare and contrast the following macro definitions:
1> (define INCREMENT1
(lambda macro [variable amount]
@(setq ,variable (+ ,variable ,amount)) ))
1> (define INCREMENT2
(lambda macro [variable amount]
@(,↑setq ,variable (,↑+ ,variable ,amount)) ))
The ‘standard’ definition is INCREMENT1. INCREMENT2 does not depend on the bindings of SET and + in the environment in which it is used. Which one better captures the intuitive notion of incrementing?