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: Marcin Borkowski
Subject: Re: Which Elisp types are mutable?
Date: Sat, 05 Jun 2021 21:19:35 +0200
User-agent: mu4e 1.1.0; emacs 28.0.50

On 2021-06-05, at 14:58, Philipp <p.stephani2@gmail.com> wrote:

>> 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.

Well, in my book, "you can't mutate them" is.  You always /can/ mutate
a string, but of you do it in certain circumstances, you're asking for
trouble.

>> 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.)

Ah, I see.  For me, a symbol is one thing, and what is in its
function/value/properties cells is another.

Best,

-- 
Marcin Borkowski
http://mbork.pl



reply via email to

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