[plt-scheme] Using generated names for top-level bindings

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Sep 16 11:59:55 EDT 2004

At Wed, 15 Sep 2004 21:36:57 -0400 (EDT), Andre van Tonder wrote:
> Is the following error legitimate?
> 
> (define-syntax test
>    (lambda (stx)
>      (syntax-case stx ()
>        ((_) (with-syntax ((name (car (generate-temporaries
>                                         (list (syntax _))))))
>               (syntax (begin
>                         (define name 1)
>                         (display name))))))))
> 
> (test)
>    ==> compile: bad syntax; reference to top-level identifiers is not
>        allowed, because no #%top syntax transformer is bound in: test13

One solution is to change

 (display name)

to 

  (display (#%top . name))


I'm not happy with this solution, and I'm working on a better one.

Matthew



Posted on the users mailing list.