Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Nested quasiquotation question.

0 views
Skip to first unread message

pmarin

unread,
Feb 25, 2010, 10:38:16 AM2/25/10
to
Hi all.

In the expression:

`(a `(b ,(+ 1 2) ,(foo ,(+ 1 3) d) e) f)

that evaluates to

(a (quasiquote (b (unquote (+ 1 2)) (unquote (foo 4 d)) e)) f)

Why (+ 1 3) is evaluated and (+ 1 2) not?

Pascal J. Bourguignon

unread,
Feb 25, 2010, 11:24:06 AM2/25/10
to
pmarin <paco...@gmail.com> writes:

The commas are associated to the closest quasiquote. The comma of ,(+ 1
2) is associated to the quasiquote before (b, which is inside the
quasiquote before (a. Therefore it cannot be evaluated, since it is
(quasi)quoted. On the other hand, the comma of ,(+ 1 3) being inside an
unquote form, is associated to the quasiquote before (a, and it can be
evaluated.

Clearly, comma means unquote. It's like parentheses.

`(a `(b ,(+ 1 2) ,(foo ,(+ 1 3) d) e) f)

(quote (a
(quote (b
(unquote (+ 1 2)) ; quote quote unquote --> quote
(unquote (foo ; quote quote unquote --> quote
(unquote (+ 1 3)) ; quote quote unquote unquote --> eval
d)) ; quote quote unquote --> quote
e)) ; quote quote --> quote quote
f)) ; quote --> quote


--
__Pascal Bourguignon__

pmarin

unread,
Feb 25, 2010, 12:20:02 PM2/25/10
to
On Feb 25, 5:24 pm, p...@informatimago.com (Pascal J. Bourguignon)
wrote:

Good explanation. Thank you.

0 new messages