[plt-scheme] Using generated names for top-level bindings
I ran into this problem a few months ago. I'm not sure if it's intended
behavior or not, but I worked around it by using 'datum->syntax-object'
instead of just 'syntax' for the argument to 'generate-temporaries'.
This seemed to give the generated ids a suitable lexical environment.
Greg
On Wed, 15 Sep 2004, Andre van Tonder wrote:
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> 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
>
> I know how to use gensym to do it, but par 14.6 of the Help Desk appears
> to discourage it: "...do not use gensym or string->uninterned-symbol to
> construct an identifier for a top-level or module binding."
>
> Andre
>