Common Lisp's macro system is defmacro
, which is a procedural macro system that allows you to execute arbitrary Lisp code at macro expansion time to transform code represented as data structures in quite a natural way. defmacro is very powerful, yet simple to understand and use.
The macro system of R5RS is syntax-rules
, a hygienic, pattern-matching macro system. In contrast to defmacro, you cannot simply execute Scheme code in your syntax-rules macros. Instead, you must transform code using a special rule language. syntax-rules provides automatic hygiene, and most macros written using it are arguably more readable than the same ones written using defmacro
, but on the other hand, the syntax-rules language is pretty limited, which makes the macro system awkward to use in more complex cases and consequently less general than defmacro in practice.
Finally, R6RS adds yet another macro system, which is called syntax-case
. It tries to combine the benefits of both procedural and pattern-matching macro systems by unifying the two concepts. This yields a macro system that is both hygienic by default and strictly more powerful than defmacro(*), but also adds a significant amount of complexity.
There are also other approaches to combining the power of procedural macros with hygiene, such as syntactic closures
and explicit renaming
. Support in Scheme systems tends to vary, and I'm not aware of a Common Lisp implementation that supports any kind of procedural hygienic macros, but if you're interested in learning more about macro systems, these are some things to google for.
Personally, I like the trade-off between power and simplicity chosen by defmacro, but I must confess that I don't have any real-world experience in using other kinds of macro systems, so take this opinion with a grain of salt.
(*)or at least it seems so, see for example: http://groups.google.com/group/comp.lan ... 7a167f4589