Kaz Kylheku <kkylheku@[EMAIL PROTECTED]
> writes:
> You don't always have the luxury of being able to set up this lexical
> environment. For instance you have no way to do this in a macro.
>
> What if this is the case:
>
> (defun my-list (&rest args) (some-macro args))
>
> SOME-MACRO cannot generate the (let ...) around the DEFUN.
Right. Well, this is the thing for which there is LOAD-TIME-VALUE.
For anyone not remembering the history... and there are days where I'm
not sure I do either...
I vaguely recall that in Maclisp there was a magic list [a random
place in my memory says it was called the "pratt stack" (probably
named after Vaughan Pratt, of CGOL fame, since JonL White maintained
the compiler and liked to name language features after people that
requested them)] onto which you could push definitions when you were
expanding a macro in compiled code (in interpreted code, I think you
just called EVAL to effect the definition immediately--Maclisp had
tons of places where the interpreter and compiler behaved in utterly
different ways. Things pushed onto this list would end up compiled in
along with whatever was being prepared for evaluation, so macros could
rely on auxiliary functions getting compiled to sup****t them. It
might even have gotten the order right (making sure the auxiliary
function was compiled before the macro that needed it), though I don't
recall for sure ... that might be why it was called a stack.
In CL for a while, one used to just arrange to construct and compile
objects at load time, with quoted constant values that could still be
modified. The language definition is still a little blurry around that
question, since at some point we intended LOAD-TIME-VALUE to be used for
that but I'm not sure we 100% closed the door to modifiable constants
for evaluation... but I don't recommend anyone use them since there's no
need.
LOAD-TIME-VALUE, incidentally, had its origin in an earlier weird compiler
only constant [a magic otherwise-uninterned symbol, whose name was SQUID,
for self-quoting internal datum] that you could find on a secret obarray
(kind of like a package, but not as high tech) and could cons in with an
expression causing the compiler to emit code for runtime ... I think that
was how Maclisp's #, was implemented in the compiler. (In the interpreter
it acted like #. as I recall.)
The CL way of doing this is much cleaner.


|