[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to unquote arbitrary length elements in a backquote
From: |
Rock |
Subject: |
How to unquote arbitrary length elements in a backquote |
Date: |
Tue, 21 Dec 2010 19:39:46 +0100 |
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.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- How to unquote arbitrary length elements in a backquote,
Rock <=