I was looking for it, but to no avail!

Anyway, something I was wondering about. Why don't we take the best
from all possible worlds? In this case, Clojure and Scheme (R6RS). It
would be nice to have syntax-quote, unquote, and unquote-splicing as
true macros (or special forms), and keep `, ~, and ~@ (and of course
auto-gensyms) as convenient reader shortcuts. Just seems more elegant,
plus it let's you do things like building arbitrary syntax-quote
expressions with Lisp itself (lispier, heh?). Now, who would go to
such extremes? ... well, you never know :)

But, something more important! Why not adopt R6RS's expansion rules
for syntax-quotes? This is something that was hinted at even in the
Common Lisp specs, the only problem being that, at the time, Scheme
didn't entirely get it right when it came to the distributive
application of unquote applied to an unquote-splicing in a nested
syntax-quote (backquote):

Example
-------------
(def a 2)
(def b 3)
(def c 5)
(def x `(a b c))
``(~...@x) ---> `(~user/a ~user/b ~user/c)
and finally to:
(2 3 5)

But R6RS finally got it right, and now (unquote a1 a2 a3 ...) really
does what it should, so you get the exact same behavior.

R6RS defines the nested syntax-quote expansion like so:

"Quasiquote forms may be nested. Substitutions are made only for
unquoted components appearing at the same nesting level as the
outermost quasiquote. The nesting level increases by one inside each
successive quasiquotation, and decreases by one inside each
unquotation."

This is, curiously, more or less how Paul Graham puts it for Common
Lisp in his ANSI Common Lisp book. And, by the way, I've noticed that
SBCL employs this exact rule when expanding backquotes.

The upshot (among other things) for Clojure is that, if Rich likes the
idea, we would finally get a decent, human-understandable, expansion
of syntax-quote forms as well.

Compare the above:
``(~...@x) ---> (clojure.core/seq (clojure.core/concat (clojure.core/
list user/a user/b user/c)))

to this:
``(~...@x) ---> `(~user/a ~user/b ~user/c)

or, at most:
``(~...@x) ---> (syntax-quote ((unquote user/a) (unquote user/b)
(unquote user/c)))

And that was a really simple nested syntax-quote. I wouldn't even want
to try tackling more complex ones.

Anyway, just an idea.

Rock

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to