[plt-scheme] define-for-syntax, or lack thereof

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sat Aug 3 08:32:22 EDT 2002

> How come there is no define-for-syntax form? 

Limited imagination on the part of the implementor.

> When I have a syntactic
> operation that is commonly used in the macros of one module, but nowhere
> else, it is kind of tedious that I have to make a separate module where to
> put the definitions for those operations. Would inline definitions for the
> transformer environment somehow break the phase separation?

No, that would work fine. I just wasn't able to see this while working
out the first specification and implementation.

> Also, why is there no begin-for-syntax? Even the paper on the module system
> system uses that in code examples, and there was no mention of anything
> being wrong with it. Wouldn't a dummy syntax definition do the same thing,
> at (module) top level anyway?


In the next iteration of modules, I plan to add `begin-syntax'. It's
like a top-level `begin' --- in particular, definitions are allowed ---
except that the body expressions are shifted into the next phase.

  (require-for-syntax ....)
will expand to
  (begin-syntax (require ....))
  (define-for-syntax ....)
could be written
  (begin-syntax (define ....))

In addition, `begin-syntax' could be nested in `begin-syntax' to get
forms such as `require-for-syntax-for-syntax'.

Hopefully I'll be able to implement this sometime in the fall. (I had
hoped for this summer, but there was no time.)


Posted on the users mailing list.