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 #138 received at 40671 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
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: Fri, 24 Apr 2020 19:22:22 -0700
[Message part 1 (text/plain, inline)]
On 4/22/20 5:49 PM, Michael Heerdegen wrote:

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

No, because the list is not part of the expression that is being evaluated.
However, something like this could cause trouble:

(let ((l (list 'lambda '(x) '(setcdr l x))))
  (eval (list l l)))

because it modifies the list l while it is evaluating it. (As it happens, this
code behaves differently in Emacs 26 than it does in Emacs 27 - that's what you
can get with undefined behavior....)

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

Both good points. The word "executed" is already gone from the manual, and I
installed the attached patch to try to address the other point.
[0001-Tweak-mutability-doc-a-bit-more.patch (text/x-patch, attachment)]

This bug report was last modified 5 years and 2 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.