At 08:52 PM 8/27/98 -0400, Rick Campbell wrote:
Run Plugin:"c:\users\craig\mail\attach\Re Macros Scheme vs Common
Li3.ems
<0880.0002>"
Content-Type: text/plain; charset=US-ASCII
Date: Thu, 27 Aug 1998 19:43:24 -0400
From: Craig Lanning <CraigL(a)internetx.net>
At 07:13 AM 8/27/98 -0400, Rick Campbell wrote:
>
> From: sperber(a)informatik.uni-tuebingen.de (Michael Sperber [Mr.
Preprocessor])
> Date: 26 Aug 1998 14:20:32 +0200
>
> I suspect your CL actually processes the forms in some weird
> order. In any case, I strongly doubt that the CL standard
> mandates the behavior you describe.
>
>Common Lisp does not mandate much of anything regarding when expansion
>occurs. It's an implementation detail, i. e. you should not write
>code that depends on expansion happening at a certain time.
That's not really true. All forms are processed in order from left to
right. Macros are expanded as they are reached. In compiled code,
macros are expanded at compile time in such a way as not be expanded
at runtime.
I'm pretty sure that you're wrong about this. At the risk of being
hypocritical (I didn't cite spec), can you point to something in the
spec that dictates that in compiled code, macros *must* be expanded at
compile time. I believe an implementation is allowed to expand macros
at read time and then compile whatever's been previously expanded at
compile time, e. g.
See HyperSpec section 3.2.2.2 "Minimal Compilation":
All macro and symbol macro calls appearing in the source code being
compiled are expanded at compile time in such a way that they will
not be expanded again at run time. macrolet and symbol-macrolet are
effectively replaced by forms corresponding to their bodies in which
calls to macros are replaced by their expansions.
* (defmacro foo ...)
* (defun bar () ... (foo ...)) ; expand macro here
* (defmacro foo ...) ; inconsistent with first definition
* (compile 'bar) ; uses first definition of foo cuz it was already expanded
At least, I've never seen spec saying the above is taboo and I believe
that I've seen discussion saying that it's allowed.
The CL compilers that I have seen will issue a warning after the second
definition of FOO saying that functions which used the old definition will
not get the new definition.
I thought I saw something in the HyperSpec last night, but I can't find
it today.
Craig Lanning
E-Mail: CraigL(a)InternetX.net