[racket] Another macro question: making a lexically binding keyword?

From: Laurent (laurent.orseau at gmail.com)
Date: Wed May 9 05:09:32 EDT 2012

On Wed, May 9, 2012 at 11:02 AM, Eli Barzilay <eli at barzilay.org> wrote:

> A week ago, Laurent wrote:
> > Hi,
> >
> > I didn't fully read Eli's very detailed answer, so hopefully I won't
> > repeat what he said.
> >
> > Here, to me it seems the right approach is to keep hygiene, so that
> > you can scope your INDEXes as you want, and so that you know exactly
> > what happens without needing to know the details of `ranged' and
> > `interfere' to know where your indexes are bound: [...]
>
> Yes, that's a common way to deal with these problems, but it doesn't
> work well. You basically end with writing these names all over the
> place, which can become a real problem when you want to build a
> language with these things.  In our syntax parameters paper there is
> an example that shows how awkward it can get -- say that you have an
> anaphoric conditional that binds an `it', and a `loop' that binds
> `abort'.  If you want to implement a `while' loop that uses both, then
> uses of your macro would look like:
>
>  (while abort it
>    ... code that can use `abort' and/or `it' ...
>     )
>
>
So maybe a compromise would be to use parameters for most (anaphoric)
cases, but still allow to specify a lexically scoped ("hygienic") binding
for particular cases, e.g.:
(while #:abort top-while-abort #:it top-while-it
  (while
    ....use the usual `abort' for the inner loop or the `top-while-abort'
to escape the top while....)
  ....)

?

Laurent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120509/94f739fd/attachment.html>

Posted on the users mailing list.