help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is `eval' allowed to modify its argument?


From: Stefan Monnier
Subject: Re: Is `eval' allowed to modify its argument?
Date: Fri, 13 Nov 2020 18:01:48 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>> > So do we consider that a bug in `thunk-let*'?
>> Yes.  Most likely a misuse of `nreverse` or something like that.
> Exactly that, yes.  AFAIR I used `nreverse' on purpose: back then I had
> thought it would not matter.

Destructive operations on lists, like `nreverse` or `sort` should (as
a general rule) only ever be used on lists you yourself just constructed
(so you can be (almost) 100% sure you hold the one and only reference to the 
list
and nobody else will be able to witness the destructiveness).

Using it on something you received as an argument is basically always
a bug, unless it's clearly documented (as is done, for example, in the
doc of `nreverse`).


        Stefan


PS: The "almost" above is because in Elisp you can't really be sure of
    anything, thanks to things like advice.  That's why users of advice
    are warned that it's up to them to deal with any problem that may
    result of poor interaction between their code and the rest.




reply via email to

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