From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.devel Subject: gv-exander for 'list' Date: Tue, 19 Mar 2019 17:39:08 +0100 Message-ID: <87bm26stsj.fsf@web.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="18177"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: Emacs Development Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Mar 19 17:59:17 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h6I57-0004Zf-CG for ged-emacs-devel@m.gmane.org; Tue, 19 Mar 2019 17:59:17 +0100 Original-Received: from localhost ([127.0.0.1]:60303 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6I56-00040x-AJ for ged-emacs-devel@m.gmane.org; Tue, 19 Mar 2019 12:59:16 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:42570) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6I0y-0001Eu-Ig for emacs-devel@gnu.org; Tue, 19 Mar 2019 12:55:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6Hlk-0000p9-Od for emacs-devel@gnu.org; Tue, 19 Mar 2019 12:39:18 -0400 Original-Received: from mout.web.de ([212.227.15.14]:51101) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h6Hlj-0000j1-NC for emacs-devel@gnu.org; Tue, 19 Mar 2019 12:39:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1553013549; bh=7qS4XOMAEc4zTGm7Ag1oOScKK8M007dsKBqvRqFHJ/k=; h=X-UI-Sender-Class:From:To:Subject:Date; b=i9MSBLsD+nrWLonKD3BMwYGklcYM20kkD4LJdpdRpnSP2rGAGaFsIKbrwW+mb8oge 6bHjioehbIQWloUj7kqBEPaXrxpo4fSsrfbuiSGLNGk9wT1Wa7dgla6gqMV3lXiFzC hGvlzulRsQZBpHbONrc4Oaabxe3zSB9FeW0Dxgp8= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Original-Received: from drachen.dragon ([88.67.111.211]) by smtp.web.de (mrweb004 [213.165.67.108]) with ESMTPSA (Nemesis) id 0Ld2nY-1gg3ki3nCC-00i9Xk; Tue, 19 Mar 2019 17:39:09 +0100 X-Provags-ID: V03:K1:8RGhYGbSaDhACWgxR3xrPXWgmbLWuRCfEm7RonpvQxDIPvhU7L2 ikQALawBm4dIMfCXeM3F04i/anAb5maB8SEixk6eBTY+lceJwAUtXWE2btvmsjGK4hiPoam UI81X/8QfU5YTvPcYKnDaTGNTA6bww6hLC6xrFlF3SusrHxSiIN6MXKUu6reiRRn0NFI+20 SZkMee69wJe014izNs6ag== X-UI-Out-Filterresults: notjunk:1;V03:K0:8ZIF6tCkOuA=:BoC1aAentRQsczuj/7o+HS EB7RJp89NTN2/0M8m/wS3L2FnT5k1GbWvTEFFmPfhFz1TZqJ4oL/VnRfdj86LQlS3D4vwNWsi 6mrLK7RQR+91DfQSdcpLmmwYFy+C0lsBvLS4uTUFU21PN8oYvdWZpw1hxO5Xg3tmhRizgPi0r UnGxB6FahsVn/Kx7jLgvz0sQ/8RURN+sARfegAx+eoMCfT3OQshtEIs+c8rEcwc6tqjAdKk9q AWgMQr4Gpkg2gcDJKzyJhjyzrMpvC2BRXZC2Y+/U5QbRwiGgap6NWZXtYj+0Z377LE2Ox+HmV QR05Yri90MUOjorKjG+iFvruVA2XHUU9z3/LPYNdPsGA8HPFnJU6Ry5nhYDp/T35Go/PnSC9i /5D2xjfwWaM2XufolP29eMY7PHx5vDKtbLKUzqZUtzRyNcC1fpNpaGNH6u/yUDxrC1TdQ0iDb S++ndzczqqGgBlEATsasJ7HVzI/rYCRfXdRYVC1dTbbtuYCHUE7e90xSOlpQNn4w/64LbScps GM4s+r8zXTKB1Ggg9jSzHvhsL2QB340n+0naCCmJePNMs0E/fIIoN/ZD8Qe8b06WfRhs0UUwP Ku0MjHh+hM9/MUzO+VW2SFOrn0qzhWRhsJZ/sJ+bIWkGQ9e0NFUTvoK58t7N8lpjCWijbF0MT RMMAMy3d7oCERWaCLrctXsp4bmbVhHhAePD1b09N/WYEfoaT3br6ez726Cv7UQpK4bKFqQBRu JLr35PO5LHzlunbSeEPt4doa5ruAMhEp9hGS+ScNNHqbQRulCdo91W02hrfsAtCo9uzOk7wi X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.15.14 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:234373 Archived-At: --=-=-= Content-Type: text/plain Hello, while I was trying to understand the "debatable" gv expanders (`if', `cond' etc.) I had the idea of adding an expander for `list': --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-lisp-emacs-lisp-gv.el-Add-gv-expander-for-list.patch Content-Transfer-Encoding: quoted-printable =46rom 85f6743d1f5f32305da298717279491067dddb0f Mon Sep 17 00:00:00 2001 From: Michael Heerdegen Date: Tue, 19 Mar 2019 17:31:53 +0100 Subject: [PATCH] * lisp/emacs-lisp/gv.el: Add gv-expander for `list' =2D-- lisp/emacs-lisp/gv.el | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el index 4ea3ce84fc..4737f8df90 100644 =2D-- a/lisp/emacs-lisp/gv.el +++ b/lisp/emacs-lisp/gv.el @@ -519,6 +519,21 @@ gv-delay-error ,(funcall asetter `(car ,v)) ,(funcall dsetter `(cdr ,v))))))))) +(put 'list 'gv-expander + (lambda (do &rest elt-places) + ;; FIXME: when using this with letf people would expect this to + ;; create local bindings + (let ((getters+setters + (mapcar (lambda (place) + (gv-get place (lambda (g s) (cons g s)))) + elt-places))) + (funcall do `(list ,@(mapcar #'car getters+setters)) + (lambda (v) + (macroexp-let2 macroexp-copyable-p v v + (macroexp-progn + (mapcar (lambda (x) (funcall (cdr x) `(pop ,v))) + getters+setters)))))))) + (put 'logand 'gv-expander (lambda (do place &rest masks) (gv-letplace (getter setter) place =2D- 2.20.1 --=-=-= Content-Type: text/plain It could be an alternative to `progv', where the variable list isn't computed dynamically (the values list still is), but OTOH allows generalized variables. Would that make sense? Thanks, Michael. --=-=-=--