bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#40671: [DOC] modify literal objects


From: Paul Eggert
Subject: bug#40671: [DOC] modify literal objects
Date: Sun, 26 Apr 2020 18:49:23 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]