[R6RS] define-syntax vs. core/library split

Anton van Straaten anton at appsolutions.com
Wed May 10 14:25:07 EDT 2006

Michael Sperber wrote:
> I have a few nitpick questions regarding the interaction between
> `define-syntax' and the core/library split as currently proposed.  The
> core/library document says that `syntax-rules' and `syntax-case' are
> separate libraries, both exporting `define-syntax'.  Maybe I haven't
> found the right bits of information yet in the split document and the
> syntax-case proposal.
> Is the `define-syntax' in the `syntax-rules' library the same as
> that in the `syntax-case' library?  I.e., if I do
> (import (r6rs syntax-rules)
>         (except (r6rs syntax-case)
>                 define-syntax let-syntax letrec-syntax syntax-rules))
> can I do:
> (define-syntax foo (syntax-case ...))
> ?

The idea behind the current design (not explicitly stated in the 
proposal) was that an implementation might not use syntax-case as its 
primitive macro mechanism, which means that it might have a syntax-rules 
implementation based on something other than syntax-case.  In that case, 
I thought it might be cleaner for the two libraries to be self-contained 
alternatives to each other, in case an implementation treated 
transformers in different ways in the two cases.  This is a hypothetical 
situation, however.

I think your suggestion may be a better approach:

> I suspect this would be the wrong way to use these libraries anyway,
> as the RHS is evaluated in the expansion phase, and therefore the
> `syntax-rules' macro would need to be imported (for ... expand).  As
> `define-syntax' itself would beed to be imported into the run-time
> phase, this suggests that `define-syntax', `let-syntax' and
> `letrec-syntax' should probably be moved into the core, and that the
> `syntax-rules' and `syntax-case' libraries should only export
> `syntax-rules' and `syntax-case' respectively.  

I can't think of any objection to this at the moment.  If no-one else 
objects, I'll make this change to the proposal.


More information about the R6RS mailing list