[racket] Introduction to syntax-parse

From: Konrad Hinsen (konrad.hinsen at fastmail.net)
Date: Tue Sep 24 11:55:53 EDT 2013

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.

Posted on the users mailing list.