GNU bug report logs - #40671
[DOC] modify literal objects

Previous Next

Package: emacs;

Reported by: Kevin Vigouroux <ke.vigouroux <at> laposte.net>

Date: Thu, 16 Apr 2020 20:40:02 UTC

Severity: normal

Tags: patch

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Michael Heerdegen <michael_heerdegen <at> web.de>, Mattias EngdegÄrd <mattiase <at> acm.org>, 40671 <at> debbugs.gnu.org, Richard Stallman <rms <at> gnu.org>, ke.vigouroux <at> laposte.net
Subject: bug#40671: [DOC] modify literal objects
Date: Sun, 26 Apr 2020 18:49:23 -0700
On 4/26/20 5:53 PM, Dmitry Gutov wrote:

> is the behavior of "literal objects" in Emacs
> Lisp undefined when one tries to modify them?

Yes.

>>> Do you have an example of a version of Emacs where this behavior was different?
>>
>> Emacs 26.
> 
> Sorry, I don't have an Emacs 26 at hand. Should 25 suffice?

Yes.

Just tried this in
> IELM:
> 
> ELISP> (setq a '(1 . 2))
> (1 . 2)
> 
> ELISP> (setcdr a 3)
> 3 (#o3, #x3, ?\C-c)
> ELISP> a
> (1 . 3)

Yes, the behavior is undefined in Emacs 25 too. Undefined means that the
behavior you describe is allowed - in this instance you modified the "constant"
and got away with it.

> In Ruby, we also have "constants" and we sometimes laugh about being able to
> change them. And yet, there also you can't do it by accident.

I suppose it depends on what one means by "accident". :-) Perhaps we could agree
that accidents, whatever they are, happen more often in C....

> We better warn against modifying any values that are part of a "literal object"
> anywhere.

That's what the emacs-27 doc does, or at least tries to do.




This bug report was last modified 5 years and 56 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.