[plt-scheme] Storing syntax

From: Marco Monteiro (masm at acm.org)
Date: Tue Dec 15 11:55:25 EST 2009

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?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20091215/4075e556/attachment.html>

Posted on the users mailing list.