From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nathan Trapuzzano Newsgroups: gmane.emacs.devel Subject: Double unquote/unquote-splicing Date: Mon, 04 Nov 2013 09:03:11 -0500 Message-ID: <87wqko6z8g.fsf@nbtrap.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1383573810 22522 80.91.229.3 (4 Nov 2013 14:03:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 4 Nov 2013 14:03:30 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 04 15:03:34 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VdKke-0007a3-TV for ged-emacs-devel@m.gmane.org; Mon, 04 Nov 2013 15:03:33 +0100 Original-Received: from localhost ([::1]:50094 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdKke-0001sJ-HY for ged-emacs-devel@m.gmane.org; Mon, 04 Nov 2013 09:03:32 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41394) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdKkU-0001rr-MV for emacs-devel@gnu.org; Mon, 04 Nov 2013 09:03:29 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VdKkN-0003Cj-Ob for emacs-devel@gnu.org; Mon, 04 Nov 2013 09:03:22 -0500 Original-Received: from oproxy17-pub.mail.unifiedlayer.com ([74.220.201.171]:46714) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1VdKkN-0003CD-FQ for emacs-devel@gnu.org; Mon, 04 Nov 2013 09:03:15 -0500 Original-Received: (qmail 1874 invoked by uid 0); 4 Nov 2013 14:03:13 -0000 Original-Received: from unknown (HELO host393.hostmonster.com) (66.147.240.193) by oproxy17-pub.mail.unifiedlayer.com with SMTP; 4 Nov 2013 14:03:13 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbtrap.com; s=default; h=Content-Type:MIME-Version:Message-ID:Date:Subject:To:From; bh=ggnNhJUELtwq+ypZt8DOL6A2NOWUD7muwVlGR3KWLms=; b=MVjtTsOIzthUmdyc36KmkBVpMkAt0GmzGgf6u947cSCWB0l3wiYO9D2YFeKEYnQHBTMISu//JhiNyOmQG8iBKKaBhXgaELisbAdNOrRloc/S7zB6jhiqOj/Vb0BNDMxh; Original-Received: from [50.90.253.209] (port=47733 helo=Nathan-GNU) by host393.hostmonster.com with esmtpsa (TLSv1:CAMELLIA128-SHA:128) (Exim 4.80) (envelope-from ) id 1VdKkK-0000PI-Pw for emacs-devel@gnu.org; Mon, 04 Nov 2013 07:03:12 -0700 User-Agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3.50 (gnu/linux) X-Identified-User: {1585:host393.hostmonster.com:nbtrapco:nbtrap.com} {sentby:smtp auth 50.90.253.209 authed with nbtrap@nbtrap.com} X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 74.220.201.171 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:164924 Archived-At: This was a subject of discussion not too long ago. Someone wrote to say how unquote and unquote-splicing don't pile up properly (as in ,,@FORM or ,@,@FORM). In fact, they do work properly in the case that the inner unquote-splicing expands to just one form, but this is hardly a useful case (it's easily re-writable in other terms). On the other hand, there are useful cases of ,,@ and ,@,@ that cannot be written without rendering the code virtually unreadable. Consider: (defmacro once-only (names &rest body) (let ((gensyms (loop for n in names collect (gensym)))) `(let (,@(loop for g in gensyms collect `(,g (gensym)))) `(let (,,@(loop for g in gensyms for n in names collect ``(,,g ,,n))) ,(let (,@(loop for n in names for g in gensyms collect `(,n ,g))) ,@body))))) (defmacro once-only (names &rest body) (let ((gensyms (loop for n in names collect (gensym)))) `(let (,@(loop for g in gensyms collect `(,g (gensym)))) (append (list `let) (list (append (list ,@(loop for g in gensyms for n in names collect `(append (list ,g) (list ,n)))))) (list (let (,@(loop for n in names for g in gensyms collect `(,n ,g))) ,@body)))))) These two macros are semantically equivalent, but one is infinitely more easy to read thanks to ,,@. However, only the latter form works in Emacs when NAMES has length > 1. For the sake of readability, I'd like to propose properly implementing ,,@ and ,@,@ etc. Is this doable without major changes to the current backquote implementation? If so, is there some other reason why this should _not_ be done? Nathan