[plt-scheme] languages and syntax environments

From: Ryan Culpepper (ryanc at ccs.neu.edu)
Date: Thu Jul 12 18:27:06 EDT 2007

On Thu, 2007-07-12 at 17:25 -0400, David Van Horn wrote:
> Is there a way to define a language module that provides a transformer 
> environment for instances of modules written using the language?

The trick is to define a '#%module-begin' transformer for the language
that inserts the appropriate 'require-for-syntax' form into the module.

Use the macro stepper to see how mzscheme does it. (Disable macro
hiding.) Then look at the code that does it; it is in
src/mzscheme/src/startup.ss near the end of the file.


> For example, this language is like mzscheme but (syntax e) is always 
> rewritten to #f:
> (module syntax/#f mzscheme
>    (provide (all-from-except mzscheme syntax)
>             (rename syntax/#f syntax))
>    (define-syntax (syntax/#f stx)
>      (syntax #f)))
> (module f syntax/#f
>    ;; #f, because syntax is bound to syntax/#f in
>    ;; this environment.
>    (syntax #t)
>    ;; #t, because syntax is bound to mzscheme's syntax
>    ;; in the transformer environment.
>    (let-syntax ((f (lambda (stx) (syntax #t))))
>      (f)))
> I'd like to be able to bind syntax to syntax/#f in the transformer 
> environment for programs in this language.
> David
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.