[racket] Again on bindings visibility in eval

From: Eli Barzilay (eli at barzilay.org)
Date: Thu Jul 14 15:32:56 EDT 2011

25 minutes ago, Markku Rontu wrote:
> > Sure, if you take the TM-equivalent path then nothing is broken, of
> > course...  (That path tends to melt away all of PL into a weak *puff*
> > of irrelevance...)
> >
> I mean exactly this sense of disingenuousness when you use the word
> broken for something that people use successfully despite its warts.

Yes, I know what you mean.  If you're talking about "turing machine
equivalence", then all languages become the same, and nothing is ever
broken.  (Modulo some sub-TM langugaes, of course.)



> > > But as syntactic sugar for a DSL, where's the big problem that
> > > makes it entirely broken?
> >
> > Actually, unhygienic macros break even more glaringly for many
> > DSLs.
> 
> Which I guess is why they tend to be recommended as only syntactic
> sugar on top of a plain old functional library?

No, it's much more technical.  There are two sides for hygiene:

  (define-syntax-rule (or x y) (let ([tmp x]) (if tmp tmp y)))

one side is that this won't break:

  (let ([tmp 4]) (or #f tmp)) --should-be-> 4

This side is easy to fix using gensyms.  The other side is that this
won't break:

  (let ([if +]) (or 1 2)) --should-be-> 1

and this one is much harder to fix.  The CL solution is simple:
declare `if' a holy keyword that can never be rebound in this way.
Scheme starts with rejecting any such holy keywords, and lets you bind
anything you want.  (IOW, lexical scope above everything else.)

Since many DSLs define such things often, this becomes a real problem
faster than with other macro uses.

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


Posted on the users mailing list.