[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: MzScheme for Embedding
The biggest problem is that units can't export macros. I understand
the rationale for this, but that choice does mean that units don't
meet a pretty widespread need. I don't currently understand how
macros are scoped in MzScheme. It looks like they have a totally
separate, kind of ad-hoc mechanism for dealing with that.
Let me calrify the rationale behind this, just so that we're on the same
page.
Units (aka modules) must satisfy three criteria for us:
1. they must be compiled (analyzed) separately.
2. they must be first-class.
3. they must be dynamically loadable.
So they are full-fledged values.
Macros on the other hand are things that live at compile-time. They don't
have a value. It makes no sense to speak of passing "begin" to a function
f as in
(f begin)
This means macros must be elaborated the very moment we compile a module.
Macros can only be elaborated if we know their rewriting function (let's
not argue how it is expressed, via ` and , or via pattern-matching). That
implies that while a module's imports and exports can only be determined at
run-time, a macro must be imported/exported at compile time. Furthermore,
because modules are first-class, we can only determine at run-time which
module exchange things via import-export. All of this says:
macro export and import can't be related to value export and import.
[Anyone who claims anything else weakens one of the assumptions.]
;; ---
Our systematic conclusion is that we separate out the mechanism for
importing values into a module from the mechanism for importing macros.
We call an imported collection of macros a <language> and use unit/lang
to specify modules whose macros are imported:
(unit/lang <language> <value-imports> <value-exports> <definitions>)
A language is specified as a pair: a collection of traditional macros and a
run-time system, which is a set of bindings for the free variables
generated by macros. At the moment we use a collection path for putting
languages in. Using this pair, this expression is then elaborated into a
classical unit.
The new unit system isn't finished yet and won't come with 102, because the
person who implements this system, well, isn't finished for all kinds of
reasons ...
-- Matthias