Subject: bug#40671: [DOC] modify literal objects

From: Paul Eggert <[email-masked]>
Date: Tue, 21 Apr 2020 23:30:37 -0700

On 4/19/20 8:36 PM, Michael Heerdegen wrote:
> Paul Eggert <[email-masked]> writes:
> 
>> +  A mutable object can become constant if it is passed to the
>> +@code{eval} function, because you should not modify an object that is
>> +being or might be executed.  The reverse does not occur: constant
>> +objects should stay constant.
>> +
> 
> I don't know if what you say about the interpreter is true (I hope it is
> not),

Unfortunately it is true, for performance reasons: you can't reliably change a 
form that is currently being executed by the Lisp interpreter. This is because 
the interpreter can cache parts of such forms, or can check forms and later 
execute them under the assumption that the checks succeeded, and if the caches 
are invalid or the earlier checks no longer apply then Emacs can dump core or worse.

> "you should not modify an
> object that is being or might be executed" - isn't that quite common
> when calculating macro expansions (which, typically, are executed)?

You can modify the object before giving it to 'eval' (and macro expansion can do 
modifications like that), but you shouldn't modify it while it's being evaluated.