GNU bug report logs - #40671
[DOC] modify literal objects

Previous Next

Package: emacs;

Reported by: Kevin Vigouroux <ke.vigouroux <at> laposte.net>

Date: Thu, 16 Apr 2020 20:40:02 UTC

Severity: normal

Tags: patch

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


Message #114 received at 40671 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: Mattias EngdegÄrd <mattiase <at> acm.org>,
 40671 <at> debbugs.gnu.org, Drew Adams <drew.adams <at> oracle.com>,
 ke.vigouroux <at> laposte.net
Subject: Re: bug#40671: [DOC] modify literal objects
Date: Thu, 23 Apr 2020 02:49:30 +0200
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.