Subject: RE: bug#15122: 24.3.50; [PATCH] byte-compiler warnings about destructive functions

From: Drew Adams <[email-masked]>
Date: Sun, 18 Aug 2013 22:07:14 -0700 (PDT)

> > This StackOverflow entry suggested that the Emacs-Lisp byte compiler be
> > able to warn about the use of functions that are destructive, i.e., can
> > modify data structures in place:
> > http://stackoverflow.com/questions/17610046/elisp-destructive-operation-
> > warning Attached is a patch that provides this, at least a start.
> 
> All of those functions are used on a regular basis in perfectly
> correct code.  So just flagging every call is not going to fly.  We need
> to have some further analysis so that we don't flag all calls, but only
> those that "could be dangerous".
> 
> As it stands, your code would just flood you with false positives,
> so it wouldn't really help you find the problematic uses.

That was not the aim.  The question was not whether particular code that
uses a destructive operation is correct.  The question was whether
particular code uses a destructive operation at all.  That's all.

See the OP, which spoke of an "elisp-newbie-mode".  He requested a
feature that "adds warnings about destructive operations being used".
Not being used wrongly or problematically, just being used.

Anyway, I would agree that warning about use of a destructive function
should be turned off by default.  It's also fine with me if you ignore
the patch altogether.

I can see a use for such a warning, as I expect there are a fair number
of people who want to avoid using destructive operations in general and
might not be aware of when they might be doing so.  I mentioned Scheme's
explicit choice to name all such functions in a noticeable way.  Drawing
attention to (all) use of destructive operations is not necessarily a
useless thing, depending on the user and context.

That was the point of the patch.  It was not to detect uses that are
"problematic", such as where you forget to use `setq' after `delq' to
store the result back into the source variable, or similar.  (Yes, it
is true that the OP example was such a case.)