all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Hu Lucius <orctarorga@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: [PATCH] gv.el: minor change, cleaning up
Date: Wed, 16 Jun 2021 09:03:01 -0400	[thread overview]
Message-ID: <jwvmtrqnf6s.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CACDPnMHMLZGZ7rmC21YjSSEhvYmk+U8zPzU487Tc8g8Zj3beUw@mail.gmail.com> (Hu Lucius's message of "Wed, 16 Jun 2021 05:06:36 +0000")

> Evaluate `(macroexpand-all `(setf (alist-get key alist) value))` and
> it returns the following:
>
>   (let* () ;; /* bindings omitted */
>     (progn
>      (if p
>          (setcdr p v)
>        (setq alist
>              (cons (setq p
>                          (cons key v))
>                    alist)))
>      v))
>
> It seems to me that `(setq p ..)` is unnecessary,

It's unnecessary for `setf` (and `push`, and `cl-pushnew`, and
`cl-rotatef`, and `cl-callf` ;-) but it can be necessary for more
complex settings.  I can't remember what was the setting where I found
that I needed it, sadly.  Clearly it must be one where we use the getter
(or the setter) after having used the setter.


        Stefan




      reply	other threads:[~2021-06-16 13:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-16  5:06 [PATCH] gv.el: minor change, cleaning up Hu Lucius
2021-06-16 13:03 ` Stefan Monnier [this message]

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=jwvmtrqnf6s.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=orctarorga@gmail.com \
    /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.