[armedbear-devel] Compiler macros vs source transforms
Erik Huelsmann
ehuels at gmail.com
Mon Jul 13 21:04:28 UTC 2009
On Sun, Jul 12, 2009 at 12:15 PM, Erik Huelsmann<ehuels at gmail.com> wrote:
> While reading through precompiler.lisp, I noticed we have 3 concepts
> for transformation of lisp sources
>
> * normal macros,
> * compiler-macros,
> * source-transforms
>
> The difference between macros and compiler-macros is well documented
> in the CLHS; however, the difference between compiler-macros and
> source-transforms is unclear to me. I found that the former is
> expanded in compiler-pass1 while the latter is expanded in
> precompiler.lisp. However, when we're compiling for interpretation
> (not compilation), *in-jvm-compile* is NIL, meaning that
> source-transforms don't get expanded.
>
> The net effect would be that both source-transforms and
> compiler-macros only get expanded when we're compiling. I'm wondering
> what the benefit of source transforms is if this is really true.
I had the opportunity to talk to Peter Graves on IRC yesterday. He
explained how this works and especially, how he designed it to work in
XCL (his post-ABCL Lisp compiler off-the-ground rewrite in C++).
So, this is his take on it in XCL:
* as the CLHS documents: there can only be 1 compiler-macro per symbol
* the user is free to define his own compiler macros
The two statements above mean that the (correct) operation of the
compiler should not depend on any compiler macros.
XCL uses source-transforms to make sure the user can define compiler
macros for any symbol he or she likes.
XCL expands compiler macros in the compiler (not in the
preprocessor/macro-expander)
XCL expands source transforms after compiler macros.
I think this is the sane thing to do: it removes the dependency of
ABCL on certain compiler macros to be available.
I fully intend to implement this strategy in ABCL too. This means the
following steps:
* making source transforms out of the compiler macros currently
defined in precompiler.lisp
* moving all source transforms (and thus compiler macros) from
precompiler.lisp to compiler-pass1.lisp
* remove all expansion of compiler macros from precompiler.lisp
(moving it to compiler-pass1.lisp) - as they are not expanded when not
compiling anyway.
I hope to execute these changes in the coming week.
Bye,
Erik.
More information about the armedbear-devel
mailing list