Subject: 24.3.50; [PATCH] byte-compiler warnings about destructive functions

From: Drew Adams <[email-masked]>
Date: Sat, 17 Aug 2013 22:26:16 -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.

It covers the basic functions that can perform in-place data structure 
modification: lists, strings, vectors and other arrays, symbol properties.
These are generally the functions identified as destructive or modifying
in the Elisp manual.

A comment in the code identifies some other possible candidates that
occurred to me while browsing the manual.  Modify the list of functions
as you see fit (variable `byte-compile-destructive-functions').

I'm no expert on some of the data structure implementations, and the
manual is sometimes not so clear about whether destructive modification
occurs.  And perhaps there are cases where although the modification is
destructive at an implementation level the user need not be concerned
about that level, so such functions should not be included.  Dunno.

Perhaps also something could be done in the future wrt recognition of
particular cases for `setf' modification.

In GNU Emacs 24.3.50.1 (i686-pc-mingw32)
 of 2013-08-07 on ODIEONE
Bzr revision: 113750 [email-masked]
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --prefix=/c/Devel/emacs/binary --enable-checking=yes,glyphs
 CFLAGS=-O0 -g3 LDFLAGS=-Lc:/Devel/emacs/lib
 CPPFLAGS=-Ic:/Devel/emacs/include'