[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Instead of read macros, how about one reserved-word for process-time macro?

Here's an idea I used here as an alternative to splicing macros and other
MacLISP grunge which weren't available here, and which might in CL be a general
solution to macro->declare, argument-list macros, etc.
Have one reserved word, which in the CAR position of any form, even an
inner form, causes the CADR to be the name of a macro and the CDDR to be
a form to be passed to that macro. The result from that macro is then the
effective form to be processed instead of the original form containing the
reserved word. For example, if ! is the reserved word, and FOO is a macro,
then (A B ! FOO X Y Z) means (A B . q) WHERE q is the result of applying
FOO to the s-expression (X Y Z). For example, if FOO is a macro that
expands into the arglist (VAL1 VAL2 TMP) then (DEFUN BAR (!FOO) ...)
is effectively (DEFUN BAR (VAL1 VAL2 TMP) ...). If you want to patch
things together, use ! before CONS or APPEND, for example if FOO2 is
a macro that expands into another arglist (PTR1 PTR2) then you can get
all five args by saying (DEFUN BAR (! APPEND (! FOO) (! FOO2)) ...).

I'm a bit sloppy because this is just an idea. Should we use recursive
evaluation when passing arguments to macros or functions named after !,
or should we use EVALQUOTE conventions where args are implicitly quoted?
You can of course suppress evaluation by ' or increase evaluation by
doing (! EVAL <form>) so either way you get full flexibility. Of course
the context of the macro-expansion should be whatever context would be
doing the normal processing of the data. Note that even user data could
use this convention if the particular program doing the processing were
(advertised as) respecting this data-macro convention. Initially only a
few system utilities would respect this convention, such as the compiler
and interpretor when the data-macro appears in certain places in forms
to be compiled or evaluated, but later additional programs could install
the convention and start to advertise it. (Imagine having random data
fed into some random program that happens to respect the convention, with
that data having the ability to perform arbitrary processing before
passing the effective data to the program! Sort of like actors/objects!)