From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.bugs Subject: bug#57397: cl-letf blindly macroexpands places Date: Wed, 31 Aug 2022 03:32:28 +0200 Message-ID: <87sfldmc43.fsf@web.de> References: <877d2xdjdi.fsf@web.de> <87leralavg.fsf@web.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2057"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 57397@debbugs.gnu.org, Lars Ingebrigtsen To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 31 03:35:01 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oTCdA-0000Cs-Bg for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 31 Aug 2022 03:35:00 +0200 Original-Received: from localhost ([::1]:49712 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oTCd9-0007r6-8E for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 30 Aug 2022 21:34:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40636) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oTCbH-0006HI-1n for bug-gnu-emacs@gnu.org; Tue, 30 Aug 2022 21:33:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48035) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oTCbG-00021C-OC for bug-gnu-emacs@gnu.org; Tue, 30 Aug 2022 21:33:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oTCbG-0006kT-9i for bug-gnu-emacs@gnu.org; Tue, 30 Aug 2022 21:33:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Heerdegen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 31 Aug 2022 01:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57397 X-GNU-PR-Package: emacs Original-Received: via spool by 57397-submit@debbugs.gnu.org id=B57397.166190956625914 (code B ref 57397); Wed, 31 Aug 2022 01:33:02 +0000 Original-Received: (at 57397) by debbugs.gnu.org; 31 Aug 2022 01:32:46 +0000 Original-Received: from localhost ([127.0.0.1]:37784 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oTCaz-0006ju-OO for submit@debbugs.gnu.org; Tue, 30 Aug 2022 21:32:46 -0400 Original-Received: from mout.web.de ([217.72.192.78]:53667) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oTCau-0006ja-T9 for 57397@debbugs.gnu.org; Tue, 30 Aug 2022 21:32:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1661909550; bh=Sv7QDlkbI6oqDfesXlCEUaGFfbgdqxtZ5Xy0UkGmmbE=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=ASSsr3arzqsF9TLFLKDfNwBB/d60F3mYNAuMHJKZRarT/fXcYXmNp8x0LLBrRfsHd jWWvWG/GvI8EsggB78iuzLUwB3kPMVQNtJN0v1yX3A2hEXH+ZUgjVeJ7/LW2glmRkv I9PzZDRrBBkxjYg+r2AjMJ+GHlJI+5As23gA7GAI= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Original-Received: from drachen.dragon ([84.57.248.18]) by smtp.web.de (mrweb105 [213.165.67.124]) with ESMTPSA (Nemesis) id 1N3ouw-1pShC94384-00zi61; Wed, 31 Aug 2022 03:32:30 +0200 In-Reply-To: (Stefan Monnier's message of "Sat, 27 Aug 2022 10:48:17 -0400") X-Provags-ID: V03:K1:ERhtt+2o3cjP1hieHfh8po0yPWPro4Iv8tB3FUsV9igEGkefXNw JHd0F90nbv4Q4jsFHWD90Y9fq8ssJ/BQuNS9k38c+5/tptPKSG6WHxh1cZEHIy5a7/OGFxS pjdlNi78rNEF25qODOucLAsVcu5rFFgtURyz9kuISAQ+WeLQaE70j72W9BJf9jirmyDUBuW bFhZgeFxXIjet718kEOYg== X-UI-Out-Filterresults: notjunk:1;V03:K0:rAgGwyyAsAU=:Gc0bcqWksOz3kP09BegMd2 Hl8hLDIMcSs87yV+ERz80wVCpvddch8r+JITwJSG8tbgCMekGf6MuxPAYXagfWs8RwvHOv5Tq hmBb5xpQsk9WGbHZhMt/UB6unSChO08J8lfljIJrlqQFg2YEq+6bLflGkoePo/kfcxxTQi6yb bur+YtsLv5s6U1onG0enaUNl3SOSXNHX1G9AouZJl5KFVYWEQS4kF0fRml4qiQikM/ME6d56o aRfKm4wvcUEkcnZsWk71t5euJc1k87h5PjkEVuYx94FS2osrg3l2zqwQOWooYRHdAPAE4JmTG TYFtC9NK43dr4gYGjJ53kmnhk0eQ0DH5Ima7cB5dri3NtwyC9SCSQJOPn+l5zcXgikF3VQ0+I Q+zdr1ruUf0zgD1O6/UhcndvB2fkPgrBXjI+3z/xnnHlMIlIs1v7+Nm+h53RUZFJW+Q92LQQu gSmQ9FNcdD527e5gXukSyqwITLwCnIVPiz+jfEgr/f6GFa9MWu9kd5fhXlnlb/HitJsJSEqwz DOA8AFFFurJxxh5dMQ+O/NBimdkyAVpQPpzjc2KlJ24MWBQxjDTXh8ebFqZXtBo2AjSo4JWoJ bOBtUbmcVV6Y+s5Bn3Znc2wMkw1moorLv+LDTXAm7cOdEbqjI4NofU6pez9QxyN4BKti9ICGT ddHl5haDjHiG/UOKXvxJktwNTRC4pOLtTqUEhoBJdnRfceHUsUgtYMrGuxxNlxXYgySWpqjuz aj3sSKdqSM1KdzL+sdo2+f7KWEKwAomN14JMDO+0Hh2mqcJyGGtMY15oP7pN7jZ8t9l9oRCX X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:241156 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier writes: > > Was it necessary to really expand symbol macros to fix that bug, or is > > the purpose only to handle the following `symbolp' test correctly? > > No the problem shows up in the `gv-letplace` that follows immediately, > so by the time we get to the `symbolp` test it's too late. > But I suspect that the better fix is to skip the macroexpand call here > and to change `gv-get` so as to do a `macroexpand-1` call even if its > arg is a `symbolp`. Ok, you have obviously more insight here, so can you maybe...take over this part? > > [`gv-synthetic-place'] seems to work quite as well (using the same > > body and gv-spec) when defined as a function. > > The only downside is that the code is less efficient (the getter has to > construct the closure of the setter, then call `gv-synthetic-place` > which then just throws it away) but that should be easy to fix with > a compiler macro. Ok - does this look correct? --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Turn-gv-synthetic-place-into-a-function.patch Content-Transfer-Encoding: quoted-printable =46rom 585981019e32ff4aa1a7ce4614428744d1b55332 Mon Sep 17 00:00:00 2001 From: Michael Heerdegen Date: Wed, 31 Aug 2022 03:13:09 +0200 Subject: [PATCH] Turn gv-synthetic-place into a function This fixes Bug#57397. * lisp/emacs-lisp/gv.el (gv-synthetic-place): Make a function and add trivial compiler macro to avoid decreasing efficiency. =2D-- lisp/emacs-lisp/gv.el | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el index eaab6439ad..9c3f77d2cc 100644 =2D-- a/lisp/emacs-lisp/gv.el +++ b/lisp/emacs-lisp/gv.el @@ -532,13 +532,13 @@ plist-get (funcall do `(error . ,args) (lambda (v) `(progn ,v (error . ,args)))))) -(defmacro gv-synthetic-place (getter setter) +(defun gv-synthetic-place (getter setter) "Special place described by its setter and getter. GETTER and SETTER (typically obtained via `gv-letplace') get and -set that place. I.e. This macro allows you to do the \"reverse\" of what -`gv-letplace' does. -This macro only makes sense when used in a place." - (declare (gv-expander funcall)) +set that place. I.e. this function allows you to do the +\"reverse\" of what `gv-letplace' does. This function only makes +sense when used in a place." + (declare (gv-expander funcall) (compiler-macro (lambda (_) getter))) (ignore setter) getter) =2D- 2.30.2 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable BTW, I had trouble understanding the paragraph about the compiler-macro declare specs in (info "(elisp) Declare Form"), in particular the calling convention: | [...] When encountering a call to the function, of the form =E2=80=98(FUN= CTION | ARGS...)=E2=80=99, the macro expander will call EXPANDER with that form as | well as with ARGS... not only because of the colons, but also because it's...wrong? EXPANDER is called with one argument, and the other formal arguments are available (bound) to the corresponding argument forms, right? Could you then maybe rephrase a bit [I don't want to, my English is not good enough. I'm able to do it but it always takes much too long to find a good wording.] TIA, Michael. --=-=-=--