From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.devel Subject: [PATCH] Implement letrec without backquote? Date: Sat, 05 Nov 2016 02:39:00 +0900 Message-ID: <878tszkuvf.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1478281232 15786 195.159.176.226 (4 Nov 2016 17:40:32 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 4 Nov 2016 17:40:32 +0000 (UTC) Cc: tino.calancha@gmail.com To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Nov 04 18:40:29 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c2iTF-00013i-0Z for ged-emacs-devel@m.gmane.org; Fri, 04 Nov 2016 18:40:05 +0100 Original-Received: from localhost ([::1]:40120 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c2iTH-0001Xf-Ss for ged-emacs-devel@m.gmane.org; Fri, 04 Nov 2016 13:40:07 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:32890) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c2iSX-0001XP-R9 for emacs-devel@gnu.org; Fri, 04 Nov 2016 13:39:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c2iST-0007WT-QN for emacs-devel@gnu.org; Fri, 04 Nov 2016 13:39:21 -0400 Original-Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:33233) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c2iST-0007Ah-Hm for emacs-devel@gnu.org; Fri, 04 Nov 2016 13:39:17 -0400 Original-Received: by mail-pf0-x244.google.com with SMTP id 144so131648pfv.0 for ; Fri, 04 Nov 2016 10:39:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:cc:date:message-id:mime-version; bh=52Zk4T37MaZBSZrUAeGaVrV7U30GQ9h+ffpp2V398lo=; b=JEuCc5FeP6vItUeITQ1zNJBDVXnf1f/EsrEF0ETX5+8DA0/iXQtL6ptYFRA12AmkbT Rlk2uWMGeFlFXueNSA4w3FP30KxItO89rqMUQ1Tuk0B88qqympel5pjiwnFUjDUclkj1 b57Nf+8CScfNT0zTWZSBHLs3hQV0GNctbeW5wE1+o18PJe4UQC+wQmOMwmDe4cvzgAvy 1wlPqiYPQtfzhwF0zC4YqtmgE2P1STRnQ7uL40pzqlQvOLvt9Z2hryivNxvdyL+Zo7GO 7rniSNxAclY5kFSM4gAA6iIlpzyXgk/HKNFOU6NaDfwpqrbfoLir2CCVYavPWNR3l1+H LGPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:cc:date:message-id:mime-version; bh=52Zk4T37MaZBSZrUAeGaVrV7U30GQ9h+ffpp2V398lo=; b=bxA+1G4DDB89ALOQNFV1Qq7ablkoVKZ/+gUkxaRsI/mWmirWtCtC2TNUUJu4tn2sAZ jM6LTgXxojc5hJizMEs7GO5HjSEu+tKAbZu7Kx9TS5BDXh3D/KZE1ss2RcFVEBCThJMv xbWulNrPvZVnl90GSpNGWDVOjP61x/HYDby2B8YROmhVp3tlw1wvvrp2rvVJslfhhEmE 3FG5GEBwE6upw+D2VkJI7OsOPxkyCxugBFQz6Uj+eoRqWQRYJ2oIVgorkMYISWVEFfzV Te6SBj51Lb3muMdho6WshzK4tRyZ7ysoEMNyUv13/9PoJIxY3nZWXTzT8NlG9ibxe/wI 6R0Q== X-Gm-Message-State: ABUngvfqyPmoO1bes/ysM9Pxw4SrVvRhQSCdyZ6bYbANUiJuPBgCYsVLq2hvO7wyob/1jA== X-Received: by 10.99.49.213 with SMTP id x204mr23490348pgx.92.1478281143866; Fri, 04 Nov 2016 10:39:03 -0700 (PDT) Original-Received: from calancha-pc (57.92.100.220.dy.bbexcite.jp. [220.100.92.57]) by smtp.gmail.com with ESMTPSA id xk6sm21880673pab.26.2016.11.04.10.39.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Nov 2016 10:39:03 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::244 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:209159 Archived-At: Hi, i am sorry if this question results naive. Is there any advantage on this patch? *) I don't see significant differences neither in performance nor readability: in the patch, the macro expands to just one setq call. Initially, i thought this could be an advantage, but after running some checks i don't see differences. *) This patch doesn't use backquote, but as longer as `letrec' is not used in an early stage of the bootstrap this doesn't matter. Thank you. Tino ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >From e11cb762efa4ab7e6ea9bdc755d95d4275c6b715 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Sat, 5 Nov 2016 02:12:28 +0900 Subject: [PATCH] * lisp/subr.el (letrec): Reimplement it without backquote --- lisp/subr.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lisp/subr.el b/lisp/subr.el index fba43be..e667e85 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1529,9 +1529,9 @@ letrec ;; As a special-form, we could implement it more efficiently (and cleanly, ;; making the vars actually unbound during evaluation of the binders). (declare (debug let) (indent 1)) - `(let ,(mapcar #'car binders) - ,@(mapcar (lambda (binder) `(setq ,@binder)) binders) - ,@body)) + (nconc (list 'let (mapcar #'car binders) + (apply #'append (cons '(setq) binders))) + body)) (defmacro with-wrapper-hook (hook args &rest body) "Run BODY, using wrapper functions from HOOK with additional ARGS. -- 2.10.1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; In GNU Emacs 26.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.2) of 2016-11-03 built on calancha-pc Repository revision: abe594c0990a4e6bc72b20b7ff06b4b0c01a682c