Yeah, Quasiquotation in Lisp "https://eprints.kfupm.edu.sa/
60346/1/60346.pdf", that's the one.

I've already posted some material regarding syntax-quote in the
Learning Clojure Wiki.

As for Bawden's and Graham's tips, it basically all boils down to this
(adapted from ACL by Graham):

Syntax-quote is easiest to understand if we define it by saying what a
syntax-quoted
expression returns. To evaluate a syntax-quoted expression, you remove
the syntax-quote
and each matching tilde, and replace the expression following each
matching
tilde with its value. Evaluating an expression that begins with a
tilde causes an
error.
     A tilde matches a backquote if there are the same number of
tildes as
syntax-quotes between them, where b is between a and c if a is
prepended to an expression
containing b, and b is prepended to an expression containing c. This
means that in a
well-formed expression the outermost syntax-quote matches the
innermost tilde(s).
     Suppose that x evaluates to user/a, which evaluates to 1; and
that y evaluates to user/b,
which evaluates to 2. To evaluate the expression

``(w ~x ~~y )

we remove the first syntax-quote and evaluate what follows any
matching tilde. The
rightmost tilde is the only one that matches the first syntax-quote.
If we remove it and
replace the expression it's prepended to, y, with its value, we get:

`(w ~user/x ~user/b)

Notice how x got "resolved" to user/x. Any unqualified symbol gets
resolved in Clojure! This differentiates it (for the better) from
Common Lisp.

In this latter expression, both of the tildes match the syntax-quote,
so if we were to evaluate
it in turn, we would get:

(w user/a 2)

 A tilde-at (~@) behaves like a tilde, except that the expression it's
prepended
to must both occur within and return a list or sequence in general.
The elements of the returned sequence are then
spliced into the containing sequence. So

``( w ~x ~~@(list `a `b))

evaluates to

`(w ~user/x ~user/a ~user/b)

That's all there is to it.

The reader doesn't actually do it that way, but the algorithm produces
the same result in the end, which, as Guy Steele once put it, is all
that really matters! I would say that the above method is great for us
humans, while the reader's algorithm works perfectly for the language
(and has its advantages as well).

Finally, if you're curious to see exactly what it is that the reader
is producing, well then just "quote" the expression! That's something
that won't work with Common Lisp! Hehehe, one more win for Clojure :)
For instance, here's what you get by quoting the following:

'`(w ~user/x ~user/b)

Result:

(clojure.core/seq (clojure.core/concat (clojure.core/list (quote user/
w)) (clojure.core/list user/x) (clojure.core/list user/b)))

A lot more complicated, don't you think?

Rock



On Jan 25, 4:45 pm, Rob Wolfe <r...@smsnet.pl> wrote:
> Sean Devlin napisał(a):
>
> > Rock,
> > Could you please proved a link to Alan Bawden's paper?
>
> I guess Rock meant "Quasiquotation in 
> Lisp":https://eprints.kfupm.edu.sa/60346/1/60346.pdf
>
> BTW many thanks for your awesome videos. :)
>
> Br,
> Rob

-- 
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