[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 15:03:44 EDT 2014

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.

Posted on the users mailing list.