[racket] keep bindings in unhygienic macros?

From: Ismael Figueroa Palet (ifigueroap at gmail.com)
Date: Tue Jul 19 15:16:49 EDT 2011

Thanks Matthias and Sam, the macro expansion now works as I intended, with
the following change:

(define-syntax-rule (with-monad (<unit-f> <bind-f>) <body>)
    (let ((u <unit-f>)
          (b <bind-f>))
      (syntax-parameterize ([bind (make-rename-transformer #'b)])
                           (syntax-parameterize ([unit
(make-rename-transformer #'u)])
                                                <body>))))

2011/7/19 Sam Tobin-Hochstadt <samth at ccs.neu.edu>

> On Tue, Jul 19, 2011 at 2:06 PM, Ismael Figueroa Palet
> <ifigueroap at gmail.com> wrote:
> > Hi all, I'm trying to implement some simple macros to use monads in
> racket
> > using a Haskell-like do notation. I have the following macros, and my
> > problem is that I want the do macro to capture the bind identifier
> created
> > by with-monad, and in each recursive step of the do macro expansion keep
> the
> > same identifier. I don't know it is possible, I tried using (with-syntax
> > ((bind (datum->syntax 'bind) ))) but it doesn't work.
>
> I think the right solution here is to use syntax parameters [1].  This
> blog post by Eli provides a good intro:
>  http://blog.racket-lang.org/2008/02/dirty-looking-hygiene.html
>
> [1] http://docs.racket-lang.org/reference/stxparam.html
> --
> sam th
> samth at ccs.neu.edu
>



-- 
Ismael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110719/b9a47569/attachment.html>

Posted on the users mailing list.