From: Philipp Stephani <p.stephani2@gmail.com>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: 26624@debbugs.gnu.org
Subject: bug#26624: 26.0.50; Generalized variable `buffer-local-value' does't restore local flag
Date: Sun, 11 Feb 2018 17:54:02 +0000 [thread overview]
Message-ID: <CAArVCkSK8bcxWgTHN6b6i9G1uZO5yzX5MwBUzmj2wsAk2ucyQQ@mail.gmail.com> (raw)
In-Reply-To: <87inbcwjrm.fsf@web.de>
[-- Attachment #1: Type: text/plain, Size: 2042 bytes --]
Michael Heerdegen <michael_heerdegen@web.de> schrieb am So., 4. Feb. 2018
um 22:02 Uhr:
> Philipp Stephani <p.stephani2@gmail.com> writes:
>
> > #+begin_src emacs-lisp
> > (setq my-alist '((x . 1)))
> > (ignore (cl-letf (((alist-get 'y my-alist) 17)) my-alist))
> > my-alist
> > ==> ((y) (x . 1))
> > #+end_src
>
> > I think we should spend significant efforts to avoid surprises. In
> > this case, if it means we should remove `alist-get' as well from the
> > forms supported by `cl-letf', then I think that's what we should
> > do. The documentation for `cl-letf' clearly states: "On exit, either
> > normally or because of a ‘throw’ or error, the PLACEs are set back to
> > their original values." If it can't do that for some place form, it
> > shouldn't be allowed.
>
> But
>
> (alist-get value my-alist)
>
> doesn't change for any value (especially for y), so the alist, or the
> `alist-get' place expressions, aren't effectively changed. The object
> that represents the alist changes, however. Is that a problem or an
> internal implementation detail?
>
>
>
Since it affects user-visible behavior, I wouldn't classify it as internal
implementation detail.
It seems to me that the approach that `cl-letf` takes is too naive: binding
a generalized variable is never the same as setting it and later resetting
it to the previous value, not even for simple dynamic symbols (consider
unbound variables). Rather than having `(cl-letf ((place val)) body)`
expand to
(let ((oldval place))
(setf place val)
(unwind-protect body
(setf place oldval)))
it should rather expand to
(let ((old-state (internal-get-state place)))
(setf place val)
(unwind-protect body
(internal-reset-state place old-state)))
with suitably defined `internal-get-state` and `internal-reset-state`. For
most use cases `internal-get-state` and `internal-reset-state` could just
be `identity` and `setf`, but for the cases discussed here they would
contain additional information.
[-- Attachment #2: Type: text/html, Size: 2697 bytes --]
next prev parent reply other threads:[~2018-02-11 17:54 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-23 17:13 bug#26624: 26.0.50; Generalized variable `buffer-local-value' does't restore local flag Philipp Stephani
2017-06-17 13:10 ` Philipp Stephani
2017-06-17 18:48 ` npostavs
2017-06-18 4:17 ` Michael Heerdegen
2017-07-02 16:53 ` Philipp Stephani
2017-09-24 15:19 ` Philipp Stephani
2017-09-24 15:36 ` Michael Heerdegen
2017-09-24 15:44 ` Noam Postavsky
2017-09-24 16:42 ` Philipp Stephani
2017-09-24 17:43 ` Noam Postavsky
2017-09-29 7:50 ` Eli Zaretskii
2017-09-29 20:55 ` Philipp Stephani
2017-09-30 6:46 ` Eli Zaretskii
2017-12-26 22:19 ` Michael Heerdegen
2017-12-27 16:10 ` Eli Zaretskii
2017-12-27 19:54 ` Michael Heerdegen
2017-12-27 20:27 ` Eli Zaretskii
2017-12-29 14:08 ` Michael Heerdegen
2017-12-29 16:14 ` Eli Zaretskii
2017-12-29 16:20 ` Philipp Stephani
2022-08-21 21:38 ` Lars Ingebrigtsen
2022-08-21 22:21 ` Lars Ingebrigtsen
2022-08-22 6:53 ` Michael Heerdegen
2022-08-22 10:10 ` Lars Ingebrigtsen
2022-08-22 21:43 ` Michael Heerdegen
2022-08-23 10:28 ` Lars Ingebrigtsen
2018-01-24 14:33 ` Michael Heerdegen
2018-02-04 19:01 ` Philipp Stephani
2018-02-04 21:02 ` Michael Heerdegen
2018-02-11 17:54 ` Philipp Stephani [this message]
2018-02-11 20:56 ` 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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAArVCkSK8bcxWgTHN6b6i9G1uZO5yzX5MwBUzmj2wsAk2ucyQQ@mail.gmail.com \
--to=p.stephani2@gmail.com \
--cc=26624@debbugs.gnu.org \
--cc=michael_heerdegen@web.de \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).