30 mar 2009, at 18.08 James Long wrote:
The way Scheme48 does it is it has a special form in the module definition to import other modules for the syntax environment. It's my understand this limits you to only import complete modules (not arbitrary code) for the current module's syntax environment. It would look like this:
(module foo (imports bar baz) (for-syntax qux mumble))
The IMPORTS statement does the usual. FOR-SYNTAX imports the `qux' and `mumble' modules for foo's syntactic environment. The syntactic tower comes in to play if qux or mumble imports other packages for their syntactic environment.
This seems less arbitrary and might make it easier to implement.
Even without imports, a notion of syntactic tower is useful; it arises when defining macros inside definitions of macros.
Another small note: Black hole assumes a 1:1 mapping of modules to files, while Scheme48 doesn't. This would probably make a pure FOR- SYNTAX style implementation of the concept rather clunky from time to time, compared to doing the same thing in Scheme48. It might become very cumbersome to do macros only in the REPL, because you would be forced to create a module file for utilities, or to temporarily embed those functions inside the macro definition.
But of course, there is little actual difference in power, and it's definitely easier to define and to understand. Maybe it's worth it.
On the same note, Per, you mentioned not being satisfied with the syntax of your module definitions. It does get complex when you support renaming and other advanced features. Scheme48 has a really syntax good for doing all sorts of cool things when importing modules. You should take a peek at it if you want something different.
Interesting. I hadn't looked at Scheme48's module system. One thing in particular that I hadn't thought of is that it's possible to allow for macro expansions even inside import forms.
/Per