all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: 57397@debbugs.gnu.org, Lars Ingebrigtsen <larsi@gnus.org>
Subject: bug#57397: cl-letf blindly macroexpands places
Date: Sat, 03 Sep 2022 22:55:53 -0400	[thread overview]
Message-ID: <jwvo7vvx3rg.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87sfldmc43.fsf@web.de> (Michael Heerdegen's message of "Wed, 31 Aug 2022 03:32:28 +0200")

>> 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?

Pushed to `master`.

> Ok - does this look correct?

Looks good, yes.

> 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?

There are two cases: one is when EXPANDER is of the form (lambda ...)
and the other is when it's not (in which case it'll be a symbol naming
a function defined elsewhere).

When you write

    (defun my-foo (arg1 &optional arg2)
      (declare (compiler-macro (lambda (whole) ..blabla..)))
      ..toto..)

it is macro expanded to something more or less equivalent to:

    (defun my-foo (arg1 arg2)
      (declare (compiler-macro my-foo--expander))
      ..toto..)
    (defun my-foo--expander (whole arg1 &optional arg2)
      ..blabla..)

> 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.]

I can see the source of your confusion, but I'm not sure how to write it
better, without making it much more verbose (and risk making it yet
more confusing).

Would something like the patch below help?


        Stefan


diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi
index 983dfe2ec59..8e34fdf3640 100644
--- a/doc/lispref/functions.texi
+++ b/doc/lispref/functions.texi
@@ -2476,11 +2476,11 @@ Declare Form
 expander will call @var{expander} with that form as well as with
 @var{args}@dots{}, and @var{expander} can either return a new expression to use
 instead of the function call, or it can return just the form unchanged,
-to indicate that the function call should be left alone.  @var{expander} can
-be a symbol, or it can be a form @code{(lambda (@var{arg}) @var{body})} in
-which case @var{arg} will hold the original function call expression, and the
-(unevaluated) arguments to the function can be accessed using the function's
-formal arguments.
+to indicate that the function call should be left alone.
+
+To avoid syntactic redundancy, when @var{expander} is of the form
+@code{(lambda (@var{arg}) @var{body})} the function's formal arguments
+are automatically added to the lambda's list of arguments.
 
 @item (gv-expander @var{expander})
 Declare @var{expander} to be the function to handle calls to the macro (or






  reply	other threads:[~2022-09-04  2:55 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
2022-09-04  2:55         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
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=jwvo7vvx3rg.fsf-monnier+emacs@gnu.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=57397@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=michael_heerdegen@web.de \
    --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.