GNU bug report logs -
#40671
[DOC] modify literal objects
Previous Next
Full log
View this message in rfc822 format
Paul Eggert <eggert <at> cs.ucla.edu> 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.
This bug report was last modified 5 years and 3 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.