[racket] Again on bindings visibility in eval

From: Mark Engelberg (mark.engelberg at gmail.com)
Date: Thu Jul 14 23:40:23 EDT 2011

On Thu, Jul 14, 2011 at 4:35 AM, Thomas Chust <chust at web.de> wrote:
> While Clojure *mitigates* the problems of non-hygienic macros using
> namespaces and a shorthand syntax for freshly generated identifiers, it
> doesn't *solve* the problems. Racket's macro system, on the other hand,
> does solve the problems and since that involves some heavy lifting, it
> may seem more complicated at first glance.

I would like to better understand how Clojure's mitigation strategy is
insufficient.  Since Eli's document is all about the while macro,
let's look at Clojure's while macro.

(defmacro while [test & body]
  `(loop []
     (when ~test

What is broken about this?  I tried breaking it in a way comparable to
what Eli did in his document, e.g., binding every keyword/variable in
the macro to something non-sensical, but it didn't break.  Here's the
comparable Clojure code to what Eli did:
(def x (atom 2))
(let [loop 5 when 2 test 4 body 3 recur 4]
           (while (< @x 10)
             (println @x)
             (reset! x (inc @x))))



P.S.  I'm enjoying this discussion.  I feel like I'm finally getting a
handle on what kind of how "syntax" is represented and manipulated in
Racket.  It still seems like an awful lot of work, though, so I would
like to see more examples of why it is worth the effort.

Posted on the users mailing list.