From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Rock Newsgroups: gmane.lisp.guile.user Subject: How to unquote arbitrary length elements in a backquote Date: Tue, 21 Dec 2010 19:39:46 +0100 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=0015175cd898fce0760497eff55a X-Trace: dough.gmane.org 1292957026 21310 80.91.229.12 (21 Dec 2010 18:43:46 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 21 Dec 2010 18:43:46 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Dec 21 19:43:40 2010 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PV7BM-00077N-Iz for guile-user@m.gmane.org; Tue, 21 Dec 2010 19:43:32 +0100 Original-Received: from localhost ([127.0.0.1]:59287 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PV794-0002qt-HG for guile-user@m.gmane.org; Tue, 21 Dec 2010 13:41:10 -0500 Original-Received: from [140.186.70.92] (port=39797 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PV77l-0001uF-0q for guile-user@gnu.org; Tue, 21 Dec 2010 13:39:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PV77j-0001UT-Nc for guile-user@gnu.org; Tue, 21 Dec 2010 13:39:48 -0500 Original-Received: from mail-qw0-f41.google.com ([209.85.216.41]:35119) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PV77j-0001UG-Kx for guile-user@gnu.org; Tue, 21 Dec 2010 13:39:47 -0500 Original-Received: by qwa26 with SMTP id 26so4157623qwa.0 for ; Tue, 21 Dec 2010 10:39:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=FYA/mqZ/4ZlF0VgCDkixAPRkPvomjamw4eQFsrjLQe8=; b=vXGOXxBfqql3hfaMboOLRmNrc8DOgizTyII0Kho3g1QcRvX0y2AI9FNBdg963lQ5VQ LIdUkyiM59263WkEaks/rKRBb4pnJJuMqpoTZDovtTWXNW58LR+17s98BMPQt/MyEKbK 7C4G0US7YuVVzz294pTGg3ZINvhCPypH/r9js= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=wapq99k1sfww/kVsthnaqDkXCNgD4jUqzPlm1zenpKZQtXE21V0oMRTk28Nwj/OYs9 sSDW1pPB96PDjLd8lhBittJSTOz/HgP2r0jfpOIzJMr+sf+zxd0fiaQSadF9ZF0CYVrM Kg8vBMrdSXR20FOb/geeJ1m9uRhDPBa++goR8= Original-Received: by 10.224.67.14 with SMTP id p14mr5471330qai.260.1292956786810; Tue, 21 Dec 2010 10:39:46 -0800 (PST) Original-Received: by 10.220.186.71 with HTTP; Tue, 21 Dec 2010 10:39:46 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:8327 Archived-At: --0015175cd898fce0760497eff55a Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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. --=20 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 qu= a e l=C3=A0 questa mia condizione." (Richard P. Feynman) --0015175cd898fce0760497eff55a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Given that Guile hasn't adopted R6RS style quasiquotation yet (and I do= n't know if it ever will), here's a workaround I've come up wit= h.

This is also in reply to Hans Aberg's question re= garding Backquote simplification.

Basically, this is the story:

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

(unquote-splicing x1 x2 ... xn) ---> (unquote-splicing (a= ppend x1 x2 ... xn) [same as above]

(unquote (quot= e 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 be= cause 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 is= sue.

--
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 pe= r cambiare qua e l=C3=A0 questa mia condizione." (Richard P. Feynman)<= br>
--0015175cd898fce0760497eff55a--