all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 57397@debbugs.gnu.org, Lars Ingebrigtsen <larsi@gnus.org>
Subject: bug#57397: cl-letf blindly macroexpands places
Date: Wed, 31 Aug 2022 03:32:28 +0200	[thread overview]
Message-ID: <87sfldmc43.fsf@web.de> (raw)
In-Reply-To: <jwvwnatvjjb.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sat, 27 Aug 2022 10:48:17 -0400")

[-- Attachment #1: Type: text/plain, Size: 972 bytes --]

Stefan Monnier <monnier@iro.umontreal.ca> 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?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Turn-gv-synthetic-place-into-a-function.patch --]
[-- Type: text/x-diff, Size: 1441 bytes --]

From 585981019e32ff4aa1a7ce4614428744d1b55332 Mon Sep 17 00:00:00 2001
From: Michael Heerdegen <michael_heerdegen@web.de>
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.
---
 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
--- 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)

--
2.30.2


[-- Attachment #3: Type: text/plain, Size: 729 bytes --]


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 ‘(FUNCTION
| ARGS...)’, 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.

  reply	other threads:[~2022-08-31  1:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-25  4:42 bug#57397: 29.0.50; cl-letf blindly macroexpands places Michael Heerdegen
2022-08-25 19:33 ` bug#57397: " Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-08-27  1:43   ` Michael Heerdegen
2022-08-27 14:48     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-08-31  1:32       ` Michael Heerdegen [this message]
2022-09-04  2:55         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-28 15:44           ` Michael Heerdegen
2022-09-28 16:29             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-28 16:52               ` Eli Zaretskii
2022-09-28 17:10                 ` Michael Heerdegen
2022-09-28 17:12                   ` Lars Ingebrigtsen
2022-09-28 17:15                   ` Eli Zaretskii
2022-09-28 17:56                     ` Michael Heerdegen
2022-09-28 18:15                       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-02 18:18                         ` bug#57397: 29.0.50; " Michael Heerdegen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sfldmc43.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=57397@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.