[racket] Introduction to syntax-parse

From: Sam Tobin-Hochstadt (samth at cs.indiana.edu)
Date: Wed Sep 25 07:59:53 EDT 2013

On Wed, Sep 25, 2013 at 2:14 AM, Konrad Hinsen
<konrad.hinsen at fastmail.net> wrote:
>
>  > Maybe making the error message more specific like "Did you forget to (require
>  > (for-syntax syntax/parse)) ?" ? Or is it too specific?
>
> It would already help a lot if the error message said something about
> syntax-parse being undefined. But it complains about the pattern,
> which is kind of strange. It looks like syntax-parse is already there
> but incomplete.

The reason it complains about the pattern is that `_` is already bound
-- `syntax-rules` and `syntax-case` both work at phase 0 without any
new requires. So Racket interprets everything as function application
until it gets to the `_`, which it tries to expand and gives an error
because it's not supposed to be used as an expression.  Of course, you
didn't mean it as an expression, but as part of a `syntax-parse`
pattern, but because `syntax-parse` wasn't bound, it didn't get
recognized as a pattern.

I think the error message could be better about making this clearer,
but I can't think of a good way that doesn't build-in `syntax/parse`.

Sam

Posted on the users mailing list.