From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nic Ferrier Newsgroups: gmane.emacs.devel Subject: Re: macroexpand-all and cl-macrolet Date: Mon, 19 Aug 2013 19:14:21 +0100 Message-ID: <87r4dp1rb6.fsf@ferrier.me.uk> References: <87wqnk15nl.fsf@ferrier.me.uk> <85wqnhq3wy.fsf@inode.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1376936078 28002 80.91.229.3 (19 Aug 2013 18:14:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 19 Aug 2013 18:14:38 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 19 20:14:41 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 1VBTyR-0000e9-Vr for ged-emacs-devel@m.gmane.org; Mon, 19 Aug 2013 20:14:40 +0200 Original-Received: from localhost ([::1]:44395 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VBTyR-0004Rr-BX for ged-emacs-devel@m.gmane.org; Mon, 19 Aug 2013 14:14:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VBTyI-0004Qk-MD for emacs-devel@gnu.org; Mon, 19 Aug 2013 14:14:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VBTyD-0004Ys-BH for emacs-devel@gnu.org; Mon, 19 Aug 2013 14:14:30 -0400 Original-Received: from static.17.66.46.78.clients.your-server.de ([78.46.66.17]:43599 helo=po1.ferrier.me.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VBTyD-0004YY-4R for emacs-devel@gnu.org; Mon, 19 Aug 2013 14:14:25 -0400 Original-Received: from nferrier-Dell-System-XPS-L322X (140.35.155.90.in-addr.arpa [90.155.35.140]) by po1.ferrier.me.uk (Postfix) with ESMTP id 9025BAC0023; Mon, 19 Aug 2013 20:19:04 +0200 (CEST) Original-Received: from nics-xps (localhost [127.0.0.1]) by nferrier-Dell-System-XPS-L322X (Postfix) with ESMTP id 634188C0DB5; Mon, 19 Aug 2013 19:14:21 +0100 (BST) In-Reply-To: <85wqnhq3wy.fsf@inode.at> (Wolfgang Jenkner's message of "Mon, 19 Aug 2013 14:08:13 +0200") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 78.46.66.17 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:162890 Archived-At: Wolfgang Jenkner writes: > On Sat, Aug 17 2013, Nic Ferrier wrote: > >> Is macroexpand-all not supposed to work with macrolet? >> >> (progn >> (cl-macrolet >> ((nlet (bindings &rest body) >> `(apply >> (lambda ,(mapcar 'car bindings) ,@body) >> (list ,@(mapcar 'cadr bindings))))) >> (macroexpand-all >> '(nlet ((a 1) >> (b '(10))) >> (* a (car b)))))) >> >> => (nlet ((a 1) >> (b (quote (10)))) >> (* a (car b))) > > However, the following form evaluates to the desired expansion of nlet. > It is inspired by the description of `macroexpand' in the CLHS, in > particular by the remark about `macrolet' and the examples given there, > see > > http://www.lispworks.com/documentation/HyperSpec/Body/f_mexp_.htm > > (progn > (require 'cl-lib) > > (cl-defmacro macroexpand-all-locally (form &environment env) > `(macroexpand-all ,form ',env)) > > (cl-macrolet > ((nlet (bindings &rest body) > `(apply > (lambda ,(mapcar 'car bindings) ,@body) > (list ,@(mapcar 'cadr bindings))))) > (macroexpand-all-locally > '(nlet ((a 1) > (b '(10))) > (* a (car b)))))) That's brilliant Wolfgang, I don't understand it yet, but I have the manual so I'll go find out. Thanks again. PS, this is for an EmacsLisp->JavaScript compiler, so thanks for helping to make such an abomination possible :-) Nic