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: Re: Double unquote/unquote-splicing Date: Mon, 04 Nov 2013 12:59:21 -0500 Message-ID: <874n7sf3pi.fsf@nbtrap.com> References: <87wqko6z8g.fsf@nbtrap.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1383587974 8426 80.91.229.3 (4 Nov 2013 17:59:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 4 Nov 2013 17:59:34 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 04 18:59:39 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 1VdOR8-0001SF-G4 for ged-emacs-devel@m.gmane.org; Mon, 04 Nov 2013 18:59:38 +0100 Original-Received: from localhost ([::1]:51324 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdOR8-0002BA-38 for ged-emacs-devel@m.gmane.org; Mon, 04 Nov 2013 12:59:38 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45536) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdOR0-0002B2-Tm for emacs-devel@gnu.org; Mon, 04 Nov 2013 12:59:36 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VdOQv-00070m-Fs for emacs-devel@gnu.org; Mon, 04 Nov 2013 12:59:30 -0500 Original-Received: from oproxy18-pub.mail.unifiedlayer.com ([69.89.17.20]:59519) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1VdOQv-00070K-6f for emacs-devel@gnu.org; Mon, 04 Nov 2013 12:59:25 -0500 Original-Received: (qmail 10395 invoked by uid 0); 4 Nov 2013 17:59:23 -0000 Original-Received: from unknown (HELO host393.hostmonster.com) (66.147.240.193) by oproxy18-pub.mail.unifiedlayer.com with SMTP; 4 Nov 2013 17:59:23 -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:In-Reply-To:Date:References:Subject:Cc:To:From; bh=u9bKOG0OaGgSPoaHOZBEqIzMyOAKTGI6fSqNxBRVNA8=; b=sARgLplUcK45QeSigTPSnoDyoTtwV7hKExL7vyOPL3Q7KhL54XBxvWc2sMHw/EePr99VLDaf58DudDQgY1vdeurxjzeeIAsCmnrkzeFb5oXjX8jL7KrEqKNRplrufQyG; Original-Received: from [50.90.253.209] (port=48912 helo=Nathan-GNU) by host393.hostmonster.com with esmtpsa (TLSv1:CAMELLIA128-SHA:128) (Exim 4.80) (envelope-from ) id 1VdOQs-0000yQ-UI; Mon, 04 Nov 2013 10:59:23 -0700 In-Reply-To: (Stefan Monnier's message of "Mon, 04 Nov 2013 12:27:00 -0500") 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: 69.89.17.20 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:164936 Archived-At: Stefan Monnier writes: > There are two reasons why I'm resisting it: > 1- the above code looks clean, but I can't understand it at all. > Your alternative code is less clean and not easy to understand, but > I *can* understand it. We'll just have to disagree there. But even granting that the latter is easier to understand, I can't imagine anyone figuring out how to write it from scratch. > 2- Since we don't allow (\` (a (\, 1 2 3))), it's weird to allow > ``(a ,,@x) since one possible expansion for it when x=(1 2 3) is > (\` (a (\, 1 2 3))). > Another way to say it is that we should allow (\, 1 2 3) and (\,@ > 1 2 3), but that can't be used with the ,e and ,@e syntax, so it'll > stay as a second-rate citizen. This is incorrect. ``(a ,,@x) where x=(1 2 3) would evaluate to (\` (a (\, 1) (\, 2) (\, 3))). The first comma in ,,@ has the effect of being applied member-wise to each element spliced out of ,@. Cf. CLHS `Backquote' (http://www.lispworks.com/documentation/HyperSpec/Body/02_df.htm). > Isn't the above the same as > > (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 (,@(list ,@(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))))) I believe so. (FWIW, I don't think it's that easy to tell, though I'm not great at this. I derived the second form I presented from the first form step-by-step using the rules in CLHS.) The bottom line to me is that the behavior of Elisp differs from both CL and Scheme, and there doesn't seem to be a good reason for it. In further support of my argument :) "The backquote syntax was particularly powerful when nested. This occurred primarily within macro-defining macros; because such were coded primarily by wizards, the ability to write and interpret nested backquote expressions was soon surrounded by a certain mystique. Alan Bawden of MIT acquired a particular reputation as backquote-meister in the early days of the Lisp Machine." - "The Evolution of Lisp", Gabriel, Steele. I lifted that quote from a StackOverflow thread and have no idea whether it's authentic. But I think it's true.