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: Tue, 21 Apr 2020 23:30:37 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

On 4/19/20 8:36 PM, Michael Heerdegen wrote:
Paul Eggert <eggert@cs.ucla.edu> 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.





reply via email to

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