[racket] define-syntax-class
What am I missing in the code below (reproduced from the "Fortifying
Macros" paper)? When run, this gives me an error: "syntax-parse: not
defined as syntax class in: binding". If I move the syntax class
definition into the bodies of define-syntax, then it works, but that
defeats the purpose of being able to define a reusable syntax class...
#lang racket/base
(require syntax/parse
(for-syntax syntax/parse
racket/base))
(define-syntax-class binding
#:description "binding pair"
(pattern [var:identifier rhs:expr]))
(define-syntax (let stx)
(syntax-parse stx
[(let (b:binding ...) body:expr)
#:fail-when (check-duplicate-identifier (syntax->list #'(b.var ...)))
"duplicate variable name"
#'((λ (b.var ...) body) b.rhs ...)]))
(define-syntax (let1 stx)
(syntax-parse stx
[(let1 b:binding body:expr)
#'((λ (b.var) body) b.rhs)]))
Thanks in advance,
--- nadeem