[r6rs-discuss] R6 counterproposal

From: R. Kent Dybvig <dyb>
Date: Tue, 29 May 2007 08:43:35 -0400

> > Give a trivial definition of syntax-case using defmacro and I would
> > grant you that the two are equivalent in expressive power.
>
> A complicated and tricky definition would be just as good for power.
>
> > you cannot do the converse.
>
> I would like to be shown that.

Defmacro and syntax-case macros can both perform arbitrary transformations
on the input they are given.

One difference is the inputs they are given: defmacro macros are fed raw
s-expressions, while syntax-case macros are fed syntax objects that also
contain scope information. Another difference is the expander itself.
The syntax-case expander (for example) renames identifiers (in effect, at
least) in the context of a macro call so that the identifier "if"
introduced into the output of the macro resolves to the binding of "if"
where the macro was defined rather than to the "if" bound in the context
of the macro call. The defmacro expander doesn't do that.

The lack of scope information in the input and the lack of support from
the expander cannot be corrected by any transformation of the defmacro
macro itself; if the information and support aren't provided, they aren't
provided.

To give defmacro macros equivalent power, one would have to rewrite the
defmacro expander or, possibly, all of the core transformers. In the end,
one would end up with a hygienic expansion system.

Kent
Received on Tue May 29 2007 - 08:43:35 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC