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

From: Michael Heerdegen <[email-masked]>
Date: Thu, 23 Apr 2020 02:49:30 +0200

Paul Eggert <[email-masked]> writes:

> > A mutable object cannot be changed to a constant
>
> Sure they can. This idea is common in other languages, e.g., see
> Object.freeze method in JavaScript. There's no reason Emacs Lisp can't
> use the idea.

Ok.  I still have questions and objections about your additions:

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

`eval' is used quite rarely.  Can what you describe happen under other
circumstances, or does it only happen to `eval'?  E.g. what about this
case for example:

  (let ((l (list 1 2 3)))
    (funcall (lambda () l)))

Has the list become a constant?

I ask because the sub-clause "because you should not modify an object
that is being or might be executed" is totally different statement than
that about `eval'.  A list literal (1 2 3) or a string as in the example
in your answer to Drew are surely not executed, as they are not valid
forms.  They are part of a program.  But anything a macro generates also
becomes part of a program.  Maybe I misread "might be executed" as
"might be executed in the future" and you actually meant something like
"might (currently) be executed (as part of the expression the
interpreter currently executes).

BTW, speaking about Lisp the term "evaluate" is probably preferable to
"execute" I think.

Thanks,

Michael.