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

From: Andre van Tonder (andre at now.het.brown.edu)
Date: Wed Sep 15 21:36:57 EDT 2004

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


Posted on the users mailing list.