[plt-scheme] define-literal-set errors

From: Neil Toronto (ntoronto at cs.byu.edu)
Date: Fri Sep 25 14:33:38 EDT 2009


First error:

(require (for-syntax syntax/parse))
(define-literal-set bars (bar))
; expand: unbound identifier in module in: define-literal-set


(require syntax/parse)
(define-literal-set bars (bar))

But I have to (require (for-syntax syntax/parse)) because I'm using it 
within define-syntax. Is it typical to have to require a module 
for-syntax and not for-syntax?

Second error:

(require syntax/parse
          (for-syntax syntax/parse))

(define-literal-set bars (bar))

(syntax-parse #'bar #:literal-sets (bars)
   [bar  #'0]
   [x    #'1])
; = #'0

(define-syntax (foo stx)
   (syntax-parse stx #:literal-sets (bars)
     [(_ bar)  #'0]
     [(_ x)    #'1]))
; syntax-parse: expected identifier defined as a literal-set in: bars

If I comment out the definition of (foo stx), the macro stepper says 
that "bars" is unbound in the transformer phase. I'm fairly sure this is 
not my error. In the meantime, is there a way to copy the definition of 
"bars" into the transformer phase?

Is the problem that the people making the library aren't using it like 
they intend other people to use it? Or am I using it wrong? I *could* 
make a separate module where my macros are all defined in the standard 
phase and require it for-syntax, but I'd rather keep one-off experiments 
like the one I'm doing in a single file.


Posted on the users mailing list.