Preferences

So you might think, but macro-expansion as it is implemented in mainstream Lisp dialects is separate from compilation and isn't informed by compilation.

A form to be compiled is first subject to expansion, and then the expanded result, now devoid of macros is compiled.

Implementations that have multiple modes of processing, such as both a compiler and interpreter, share the macro expander between them.

There is redundancy between macro expansion and compilation. The macro expander has to understand and properly traverse special forms, and build up an environment structure that follow lexical scopes. Then the compiler has to do the same. Of course, the compiler won't have macro content in its environment stacks (lexical macros); those are gone.


I'm a Clojurian and even though macroexpansion and compilation are well delimited, they are still processed within the same pipeline, namely clojure.lang.Compiler. Lexical scope is determined once and macroexpansion happens progressively, when the compiler stumbled upon expandable forms.

I should have said "build-time state". Anyway I still think the benefits the lisp model of compilation can bring to a language that wants more compile-time computations are not to be found in some mythical homoiconic property of lisps, but in build time state. This allow you to have meta-programming pipelines without the kind of friction this usually requires and that come in the shape of complex build systems that wrap around your compiler rather than living within it.

This item has no comments currently.

Keyboard Shortcuts

Story Lists

j
Next story
k
Previous story
Shift+j
Last story
Shift+k
First story
o Enter
Go to story URL
c
Go to comments
u
Go to author

Navigation

Shift+t
Go to top stories
Shift+n
Go to new stories
Shift+b
Go to best stories
Shift+a
Go to Ask HN
Shift+s
Go to Show HN

Miscellaneous

?
Show this modal