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

From: Vincent St-Amour (stamourv at ccs.neu.edu)
Date: Fri May 4 15:54:56 EDT 2012

I don't think that's what Marijn was suggesting.

I understood it as:

    (define-syntax-rule (define-complex real-name imag-name rhs)
      (define real-name (real-part rhs))
      (define imag-name (imag-part rhs)))

    (define-complex r i 1+2i)

=>

    (begin
      (define r (real-part 1+2i))
      (define i (imag-part 1+2i)))


Marijn, is this what you meant?

Vincent



At Thu, 3 May 2012 10:23:17 -0400 (EDT),
J. Ian Johnson wrote:
> 
> 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
> 
> _________________________
>   Racket Developers list:
>   http://lists.racket-lang.org/dev


Posted on the dev mailing list.