guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What's the status of modules and macros?


From: Marius Vollmer
Subject: Re: What's the status of modules and macros?
Date: 13 May 2001 16:43:22 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.102

Rob Browning <address@hidden> writes:

> I've seen several comments to the effect that the current module
> system has a real problem with macros in that you can't have a macro
> expand into code that refers to non-exported bits of the module.  Is
> that still true?

Yes.

> If so, is it fixable without major surgery?  If so, how?

The fix, as far as I see it, is to use syntax-case and extend it to
handle the module system issues explicitely.  I haven't looked at the
code, but I imagine something like the following:

Syntax-case works by renaming all lexical variables in a special way
so that unwanted name-clashes are avoided.  I want to extend this
rewriting so that references to top-level variables are `annotated'
with the module that they are to be found in.  This could be done with
a new special form that is memoized into a gloc.

More specifically, without having really thought it thru, the `syntax'
special form will make this annotation by replacing all references to
free variables with something like `(:module-ref VAR MOD)' where VAR
is the symbol that denotes the variable and MOD is the name of the
module that is to be used to do the lookup (or the module itself, not
sure yet).  The memoizer will specially recognize the :module-ref
keyword and turn it into a gloc (using the observer mechanism to
perform re-lookups when the symbol/variable mapping in MOD changes).

If this is used exclusively, all references to top-level bindings are
explicit, and we wouldn't need to store the lookup closure at the
bottom of the lexical environment.


The downside to this fix is that it works only with syntax-case, which
is still only an optional feature of Guile.  Defmacros could use it as
well, but only manually and non-portably, which might well be
acceptable.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]