Wednesday April 11,1979 FQ+7D.0H.20M.8S. - JONL -
1) New features for DEFMACRO: MACRO-EXPANSION-USE and temporary
switch overrides for the free-variable type switches.
2) OWN-SYMBOL - a declaration for disassociating any systemic properties
from a symbol when compiling a file.
3) MACRO-EXPAND in the compiler - a macro-expander for all levels.
____________________________________________________________________________
1) New features for DEFMACRO: MACRO-EXPANSION-USE and temporary
switch overrides for the free-variable type switches.
MACRO-EXPANSION-USE for "memorizing" macro expansions
in a hash-array and for displace'ing macros in which the
call is displaced in an "back-up'able" manner.
Temporary overrides for the three macro-definition switches
(namely DEFMACRO-DISPLACE-CALL, DEFMACRO-FOR-COMPILING, and
DEFMACRO-CHECK-ARGS). This feature is available for
DEFMACRO and DEFUN/& and MACRO.
1a) Chuck Rich's macro annotation package (MACROD) and Ken Kahn's
macro expansion package have been added to MACLISP's DEFMACRO
facility. A new runtime switch (as opposed to macro definition
time switch) has been added, MACRO-EXPANSION-USE:
If MACRO-EXPANSION-USE is set to MACROMEMO, then Rich's hash-
array "memoizer" will remember previously-expanded macro calls,
and not re-expand unless the macro is redefined (via DEFMACRO);
If MACRO-EXPANSION-USE is set to MACROEXPANDED, then Kahn's
style "displacer" will displace the original call with a form
which remembers both the old original, and the expansion, and
not re-expand unless the macro is redefined (via DEFMACRO);
GRINDEF is smart about these "displaced" forms.
In the runtime environment, macros produced while
DEFMACRO-DISPLACE-CALL is non-null will pay attention to the global
variable MACRO-EXPANSION-USE (default = () ).
MACRO-EXPANSION-USE:
= MACROEXPANDED - Displace the original cell with a form like
(MACROEXPANDED <name>
<version-number>
<original-form>
<expansion>)
Thereafter, the macro named MACROEXPANDED will
return the <expansion> until either the value of
MACRO-EXPANSION-USE changes, or the <version-number>
of the original macro changes (such as by loading
in a new definition of the macro).
= MACROEXPAND - Same as above; for those who can't spell.
= DISPLACE - Displace the original cell with the expansion of the
macro-form. There is no general way to un-do, or
"go back" after this kind of displacement.
= MACROMEMO - Remember the expansions is a hasharray, where the
global variable MACROMEMO is a dotted pair of the
number-of-buckets and the array pointer itself.
All "memorized" expansions can be forgotten merely
by doing (RPLACD MACROMEMO () ).
= () - None of the above, i.e. merely expand the macro
and return that value.
Pretty-printing of forms displaced with MACROEXPANDED is controlled by
the global variable GRIND-MACROEXPANDED: if T, then only the
expanded form will be printed; if (), then only the original form
will be printed. (Default = () )
As an aid in debugging, the global variable LAST-MACROEXPANDED-LOSER
holds a ptr to the last cell visited by MACROEXPANDED
1b) The three switches relevant to macro defining time (as opposed
macro expansion time) may be temporarily overridden. These
switches are DEFMACRO-DISPLACE-CALL, DEFMACRO-FOR-COMPILING, and
DEFMACRO-CHECK-ARGS. If the "name" part of a DEFMACRO usage is a
list (instead of a symbol), then the first element is taken as the
"name", and the rest of the list is treated like a form to SETQ,
that is, alternating items in the list are names for the switches
and a form that is evaluated to get the switch value. For example:
(DEFMACRO (RLIST DEFMACRO-DISPLACE-CALL 'T DEFMACRO-CHECK-ARGS ()) (X Y)
`(LIST ,y ,x))
will make a macro for RLIST which will be of the run-time
displacing type as explained above, regardless of the global setting
of the switch DEFMACRO-DISPLACE-CALL; also it will not insert any
code into RLIST to check for proper number of args being passed.
This capability, for DEFMACRO-DISPLACE-CALL, rather outdates the
function DEFMACRO-DISPLACE, for any call to it could merely be
replaced by a call to DEFMACRO with a temporary override of the
switch DEFMACRO-DISPLACE-CALL.
As a reminder, the meaning of these three switches is reproduced here:
DEFMACRO-DISPLACE-CALL if non-null, the resultant macros do a runtime
(default = T) test of MACRO-EXPANSION-USE for possible
displacement and/or "memoizing" in a hasharray.
DEFMACRO-FOR-COMPILING determines whether the macros produced will be
(default = T) of the form that gets compiled by COMPLR
(in either case, COMPLR "remembers" them).
DEFMACRO-CHECK-ARGS determines whether there should be code to carry
(default = T) out number-of-args checking at runtime.
2) OWN-SYMBOL - a declaration for disassociating any systemic properties
from a symbol when compiling a file.
E.g. (DECLARE (OWN-SYMBOL PUSH UNWIND-PROTECT))
will REMOB the two symbols PUSH and UNWIND-PROTECT, and thus
subsequent usages of them in the file will appear to be "fresh"
atoms. This is the surest way to disconnect all special knowledge
that COMPLR has about a particular symbol, so that it can be used
by the user in some peculiar way.
3) MACRO-EXPAND in the compiler - a macro-expander for all levels.
Item 6 of the LISP RECENT note dated Jan 27, 1979, spoke about
a switch EXPAND-OUT-MACROS, which affects the treatment of
top-level forms which are sent out to the FASL file. The
function MACRO-EXPAND is called, which performs a sort of
"meta" compilation on the form, but actually only expanding out
any macro usages (which would later be expanded and run during
load-in time). This saves the load/run-time environment the
burden of needing the whole macro-environment. This function,
MACRO-EXPAND, is available to the user for his various wants,
as it is on both obarrays.