[plt-scheme] Storing syntax

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Tue Dec 15 11:57:18 EST 2009

If you look at my Datalog language on PLaneT, I do something similar.


On Tue, Dec 15, 2009 at 9:55 AM, Marco Monteiro <masm at acm.org> wrote:
> I'm trying to store a representation of the expanded code in some module.
> I'm currently using one method that translates the syntax to an AST when
> expanding the #%module-begin in my language. I am experimenting with
> storing the syntax instead, like so:
> (define-syntax (_#%module-begin stx)
>  (syntax-case stx ()
>    [(_ . forms)
>     (let ([a (local-expand (syntax/loc stx (#%plain-module-begin . forms))
>                            'module-begin '())])
>       (with-syntax ([code a]
>                     [(_ body ...) a])
>         (syntax/loc stx (#%module-begin
>                          (mute body) ...
>                          (add-code #'code)))))]))
> . In this code, the add-code procedure stores the syntax object.
> This almost works. The problem is that the expanded code can contain
> identifiers from other modules that are not exported, so I get errors like
> "compile: access from an uncertified context to unexported variable
> from module".
> In some cases, I don't have access to the macros. For example, I'm using
> quasiquote from scheme that expands to use qq-expand that is not exported.
> Is it possible to make this, or something similar, work?
> Marco
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University

"The glory of God is Intelligence" - D&C 93

Posted on the users mailing list.