[racket-dev] implicit begin for define-syntax-rule

From: J. Ian Johnson (ianj at ccs.neu.edu)
Date: Thu May 3 10:23:17 EDT 2012

I would say no, since a "syntax rule" is a single rewrite rule. Perhaps you want a simple shim around syntax-rules?

Like:
(define-syntax-rules [(id . pat) rhs] ...+)

where id must be the same in all templates?

Simple implementation:

(define-syntax (define-syntax-rules stx)
  (syntax-case stx ()
    [(_ [(id0 pat0 ...) rhs0] [(ids pats ...) rhss] ...)
     (and (identifier? #'id0)
          (andmap (λ (i) (and (identifier? i) 
                              (free-identifier=? i #'id0)))
                  (syntax->list #'(ids ...))))
     (syntax/loc stx 
       (define-syntax (id0 stx)
         (syntax-rules stx () 
           [(_ pat0 ...) rhs0]
           [(_ pats ...) rhss] ...)))]))

-Ian

----- Original Message -----
From: "Marijn" <hkBst at gentoo.org>
To: dev at racket-lang.org
Sent: Thursday, May 3, 2012 5:39:10 AM GMT -05:00 US/Canada Eastern
Subject: [racket-dev] implicit begin for define-syntax-rule

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

would it make sense for define-syntax-rule to have an implicit begin
such that it could accept multiple forms for the template?

Marijn
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk+iUj4ACgkQp/VmCx0OL2zrmACfQ18nV7BoxV2wm4SrPyCSD0rY
z54An3Kd24mFWFVuCxQ95J1Z6I5EuEJy
=fmgP
-----END PGP SIGNATURE-----
_________________________
  Racket Developers list:
  http://lists.racket-lang.org/dev


Posted on the dev mailing list.