[racket] Introduction to syntax-parse

From: Laurent (laurent.orseau at gmail.com)
Date: Tue Sep 24 13:21:15 EDT 2013

This is a quite common pitfall into which I have myself fallen a few times,
and I guess it's not the last time.

How much work would be required to prevent people from falling into it ever
again?
Maybe saying so in the docs at the right place wouldn't hurt, but people
may still miss it.
Maybe making the error message more specific like "Did you forget to
(require (for-syntax syntax/parse)) ?" ? Or is it too specific?
Or pushing the idea further (and requiring more work, obviously), Racket's
errors could propose a list of packages where the unknown identifier can be
found, along with the require phase? Is xref able to do that currently?

Laurent



On Tue, Sep 24, 2013 at 6:20 PM, Stephen Chang <stchang at ccs.neu.edu> wrote:

> You need (require (for-syntax syntax/parse)) because you are using it
> inside a define-syntax.
>  On Sep 24, 2013 11:56 AM, "Konrad Hinsen" <konrad.hinsen at fastmail.net>
> wrote:
>
>> Hi everyone,
>>
>> I am trying to learn about syntax-parse, starting with the introduction
>> of the "Syntax" documentation.
>>
>> Unfortunately, the very first example given for the use of syntax-parse
>> doesn't work in my Racket installation:
>>
>>    Welcome to Racket v5.90.0.9.
>>    racket@> (require syntax/parse)
>>    racket@> (define-syntax (mylet stx)
>>                 (syntax-parse stx
>>                   [(_ ([var-id rhs-expr] ...) body ...+)
>>                    #'((lambda (var-id ...) body ...) rhs-expr ...)]))
>>    stdin::277: _: wildcard not allowed as an expression
>>      in: (_ ((var-id rhs-expr) ...) body ...+)
>>      errortrace...:
>>      context...:
>>       try-next
>>
>> /Users/hinsen/Development/racket/pkgs/errortrace-pkgs/errortrace-lib/errortrace/errortrace-lib.rkt:480:4
>>
>> /Users/hinsen/Applications/Racket/collects/racket/private/misc.rkt:87:7
>>
>> I tried replacing the wildcard by "mylet", but that only leads to another
>> error
>> message:
>>
>>    racket@> (define-syntax (mylet stx)
>>                 (syntax-parse stx
>>                   [(mylet ([var-id rhs-expr] ...) body ...+)
>>                    #'((lambda (var-id ...) body ...) rhs-expr ...)]))
>>    stdin::842: ...: ellipses not allowed as an expression
>>      in: ...
>>      errortrace...:
>>      context...:
>>       try-next
>>
>> /Users/hinsen/Development/racket/pkgs/errortrace-pkgs/errortrace-lib/errortrace/errortrace-lib.rkt:480:4
>>
>> /Users/hinsen/Applications/Racket/collects/racket/private/misc.rkt:87:7
>>
>> Am I doing something wrong here? Or are the examples obsolete?
>>
>> Konrad.
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130924/362ab740/attachment.html>

Posted on the users mailing list.