[plt-scheme] On hygiene and trust

From: Eli Barzilay (eli at barzilay.org)
Date: Thu Jul 9 17:13:47 EDT 2009

On Jul  9, Joe Marshall wrote:
> I wrote:
> >> (define-syntax foo
> >>   (lambda (stx)
> >>     (if (lambda-expression? (first-argument stx))
> >>         ....)))
> On Thu, Jul 9, 2009 at 12:28 PM, Eli Barzilay<eli at barzilay.org> wrote:
> > You still get that:
> >
> >  > (define-syntax (foo stx)
> >      (if (free-identifier=? #'lambda (stx-car (stx-cdr stx)))
> >        #'1
> >        #'2))
> But I want
>   (if (eq? 'lambda (cadr stx)) 1 2)
> I know it isn't the same (because of the extra baggage of syntax
> objects) but it is essentially isomorphic

It's not, of course...

> (modulo doing funny things with scope),

...just like you say here.

> so why do I have to learn a whole new set of primitives?

Why is it fine to learn a new set of primitives when you're dealing
with any kind of non-sexpr data?  (I at least hope that you're not
advocating the use of sexprs as the ultimate representation of
everything...)  In this case, the idea that a symbol can represent
identifiers is exactly what's broken, and what makes the need for a
new type.

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the users mailing list.