[racket] pass pattern vars as syntax-class args before they appear in syntax-parse pattern

From: Stephen Chang (stchang at ccs.neu.edu)
Date: Fri Jun 13 22:34:03 EDT 2014

Thanks. That works, but it leaks the syntax class abstraction a little bit.

I figured out I can also get the behavior I want with ~peek

On Fri, Jun 13, 2014 at 3:27 PM, J. Ian Johnson <ianj at ccs.neu.edu> wrote:
> I use ~and patterns to first match structure and then match syntax classes to do what you're doing.
> -Ian
> ----- Original Message -----
> From: Stephen Chang <stchang at ccs.neu.edu>
> To: Racket Users <users at racket-lang.org>
> Sent: Fri, 13 Jun 2014 15:03:44 -0400 (EDT)
> Subject: [racket] pass pattern vars as syntax-class args before they appear in syntax-parse pattern
>
> I want to do something like this:
>
> #lang racket
> (require syntax/parse)
>
> (define-syntax-class (myclass . args)
>   (pattern x:id))
>
> (syntax-parse #'(a (b c))
>   [((~var x (myclass #'(y ...))) ...
>     (y z) ...)
>    #'(x ...)])
>
> But this doesnt work because I'm trying to pass y before it is bound.
> Is there an elegant way to do this, while still preserving my
> syntax-class abstraction? If I leave x undeclared initially and then
> use #:declare, then x ... will match everything, which I dont want.
>
> I'm almost certainly missing something obvious but I can't figure it out.
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

Posted on the users mailing list.