Subject: bug#12314: 24.2.50; `add-to-history': use `setq' with `delete'

From: "Drew Adams" <[email-masked]>
Date: Sat, 8 Sep 2012 09:35:57 -0700

> > Then the manual should be corrected to state that much more 
> > explicitly than it does now.  Perhaps it shouldn't even talk
> > about destructive removal, as that will surely spread
> > confusion.  For me "destructive" means "in-place", and no
> > amount of describing how 'delete' works internally will ever
> > be able to countermand that.
> 
> Even if the element is not the first one, you always have to 
> think about other references that may exist to the cons that
> is removed.

Exactly.  That too merits an explicit mention.  That is an even more insidious
source of hard-to-find bugs.

There is no harm in driving this point home, even at the risk of some
repetition.  Destructive operations should not be used without extra care.  It
is a gotcha that newbies sometimes learn the hard way.

In particular, thinking that such operations are only about performance, and
understanding that they can be more performant, newbies sometimes start using
them right off the bat (premature optimization).  And because the gotchas only
surface in some situations, they don't necessarily notice problems right away.

IIRC, the Common Lisp manual was pretty good at essentially warning readers not
to use destructive operations unless they really understand them well.  I don't
recall just what was said, though.

A simple guideline to set your variable to the list returned by such an
operation will go a long way, I think.  But we should of course explain why
also.