[racket-dev] Dotted syntax/parse patterns and scribble/eval

From: Ryan Culpepper (ryan at cs.utah.edu)
Date: Wed Sep 21 17:43:37 EDT 2011

That's a bug. A pattern variable should always be bound to a syntax object.

Ryan


On 09/21/2011 03:39 PM, Casey Klein wrote:
> I'm confused by the behavior of syntax/parse pattern variables that
> come after dots. Sometimes they're bound to lists and sometimes to
> syntax objects.
>
> For example, in the following example, the variable `after-ones' gets
> bound to a list:
>
>     #lang racket/base
>
>     (require (for-syntax racket/base))
>
>     (begin
>       (require (for-syntax syntax/parse))
>
>       (define-syntax (m stx)
>         (syntax-parse stx
>           [(_ 1 ... . after-ones:expr)
>            (if (list? #'after-ones)
>                #''list
>                #''not-list)]))
>
>       (m 1 1 2 1 2 3)) ; 'list
>
> but it gets bound to a syntax object if I drop the variable's `expr'
> syntax-class.
>
> That is, unless you're using scribble/eval, in which case dropping the
> syntax-class does not change the behavior:
>
>     #lang scribble/manual
>
>     @(require scribble/eval)
>
>     @(parameterize ([current-eval (make-base-eval)])
>        (interaction-eval (require (for-syntax racket/base)))
>        (interaction (begin
>                       (require (for-syntax syntax/parse))
>
>                       (define-syntax (m stx)
>                         (syntax-parse stx
>                           [(_ 1 ... . after-ones:expr)
>                            (if (list? #'after-ones)
>                                #''list
>                                #''not-list)]))
>
>                       (m 1 1 2 1 2 3))))
>
> What's going on?
> _________________________________________________
>    For list-related administrative tasks:
>    http://lists.racket-lang.org/listinfo/dev


Posted on the dev mailing list.