[plt-scheme] require-for-syntax and syntax/parse

From: Neil Toronto (ntoronto at cs.byu.edu)
Date: Mon Sep 14 19:06:20 EDT 2009

This:

     (require-for-syntax syntax/parse)

     (define-syntax (blah stx)
       (syntax-parse stx
         [(_) #''blah]))

gives an error:

     expand: unbound identifier in module (transformer environment) in: 
syntax-parse

The docs for require-for-syntax say (require-for-syntax syntax/parse) 
should expand to (#%require (for-syntax syntax/parse)). But using 
(#%require (for-syntax syntax/parse)) doesn't give an error in the 
example above.


There's a related user-interface problem with the docs. There's no 
indication of what environment an identifier will be bound in. This is 
compounded by misleading example code. For example, the docs for 
syntax/parse have

     (require syntax/parse)

which is great if you're building libraries for creating syntax 
transformers but wastes your time if you're just using those libraries. 
This, along with the broken require-for-syntax, cost me a couple of 
hours recompiling from svn, because I thought my local build was broken. 
It looked like syntax-parse wasn't bound in any environment when I used 
it inside define-syntax.

Is syntax-parse within define-syntax (like syntax-case within 
define-syntax) the most common expected use case?

Is it possible to indicate in the docs what environment an identifier 
will be bound in?

Neil



Posted on the users mailing list.