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

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

Re: Which Elisp types are mutable?


From: Philipp
Subject: Re: Which Elisp types are mutable?
Date: Sat, 5 Jun 2021 14:58:02 +0200


> Am 05.06.2021 um 13:22 schrieb Marcin Borkowski <mbork@mbork.pl>:
> 
> 
> On 2021-06-03, at 14:11, Philipp <p.stephani2@gmail.com> wrote:
> 
>>> Am 03.06.2021 um 06:03 schrieb Marcin Borkowski <mbork@mbork.pl>:
>>> 
>>> Well, the subject says it all.  I could find an explicit, comprehensive
>>> list of mutable (or immutable) types in the Elisp manual.  Is it there
>>> somewhere?
>> 
>> Mutability is a property of objects, not types.
>> Some objects (numbers) are always immutable, others (markers, buffers, ...) 
>> are always mutable.  But objects of most "interesting" types (strings, 
>> lists, vectors, symbols) can be either mutable or immutable.
>> Some time ago, I filed https://debbugs.gnu.org/cgi/bugreport.cgi?bug=43557 
>> to document which objects are mutable, but unfortunately it's not yet fixed.
> 
> Thanks.  However, I still don't understand.  How can a list be
> immutable?  What about a string?  I thought these are _always_ mutable
> (although in some cases you must not mutate them, because if you do, bad
> things could happen

"You must not mutate them" is the definition of immutable.

> Also, I thought symbols are immutable.  Can you provide an example
> showing that they aren't?

Symbols are probably a weird case terminology-wise.  Here I define "mutable 
symbol" as symbol whose value and function slots can be changed (true for most 
symbols except keywords).  However, arguably other definitions are possible, 
depending on whether you see their values and function slots as "part of a 
symbol" or as something they refer to.  (The manual doesn't specify this.)


reply via email to

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