unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* How to unquote arbitrary length elements in a backquote
@ 2010-12-21 18:39 Rock
  2011-01-07 13:42 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Rock @ 2010-12-21 18:39 UTC (permalink / raw)
  To: guile-user

[-- Attachment #1: Type: text/plain, Size: 1268 bytes --]

Given that Guile hasn't adopted R6RS style quasiquotation yet (and I don't
know if it ever will), here's a workaround I've come up with.

This is also in reply to Hans Aberg's question regarding Backquote
simplification.

Basically, this is the story:

(unquote x1 x2 ... xn) ---> (unquote-splicing (list x1 x2  ... xn))
[naturally this MUST be contained within another list or vector]

(unquote-splicing x1 x2 ... xn) ---> (unquote-splicing (append x1 x2 ... xn)
[same as above]

(unquote (quote x1 x2 ... xn)) ---> (unquote-splicing (quote (x1 x2 ...
xn))) [idem]

That should cover all one's needs of applying these operators on arbitrary
length lists of elements. This works in Common Lisp as well, although
there's no need for this except in specific cases because they got it right
with backquotes from the very beginning :)

With the reader macros it comes out like this:

,@(list ...)

,@(append ...)

,@'( ... )

respectively.

Hope this helps anybody who was struggling with this issue.

-- 
Rocco Rossi

E-Mail: rocco.rossi@gmail.com
Profilo: http://www.google.com/profiles/rocco.rossi

"Sono nato senza conoscere nulla e ho avuto un po' di tempo per cambiare qua
e là questa mia condizione." (Richard P. Feynman)

[-- Attachment #2: Type: text/html, Size: 1729 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-01-07 13:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-21 18:39 How to unquote arbitrary length elements in a backquote Rock
2011-01-07 13:42 ` Ludovic Courtès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).