From: Rock <rocco.rossi@gmail.com>
To: guile-user@gnu.org
Subject: How to unquote arbitrary length elements in a backquote
Date: Tue, 21 Dec 2010 19:39:46 +0100 [thread overview]
Message-ID: <AANLkTinZZ3Sn1LyzhrPXTs2Uc8u5NEyFs_oYfmSDTsjW@mail.gmail.com> (raw)
[-- 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 --]
next reply other threads:[~2010-12-21 18:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-21 18:39 Rock [this message]
2011-01-07 13:42 ` How to unquote arbitrary length elements in a backquote Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AANLkTinZZ3Sn1LyzhrPXTs2Uc8u5NEyFs_oYfmSDTsjW@mail.gmail.com \
--to=rocco.rossi@gmail.com \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).