GNU bug report logs - #33998
27.0.50; cl-delete does not delete the first list element

Previous Next

Package: emacs;

Reported by: Deus Max <deusmax <at> gmx.com>

Date: Sun, 6 Jan 2019 17:48:01 UTC

Severity: minor

Tags: notabug

Found in version 27.0.50

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: João Távora <joaotavora <at> gmail.com>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 33998 <at> debbugs.gnu.org, Deus Max <deusmax <at> gmx.com>
Subject: bug#33998: 27.0.50; cl-delete does not delete the first list element
Date: Tue, 8 Jan 2019 18:57:12 +0000
On Tue, Jan 8, 2019 at 6:46 PM Drew Adams <drew.adams <at> oracle.com> wrote:
>
> > > Again, you should set the variable to the value
> > > returned by `cl-delete' only if that's what you
> > > want
> >
> > OK. Say you don't. Say you don't SETQ the variable
> > to the return value. What do you expect to be left
> > with in the value bound to the SEQ symbol?
> >
> > > Pretty simple, really.
> >
> > Then answer the pretty simple question above.
>
> Without setting variable `seq' (i.e., without
> the `setq'), that variable is still bound to
> whatever it was bound to prior to your invoking
> `(cl-delete thing seq)'.  Presumably it was
> bound to a cons.

It could have been bound to a vector. cl-delete (as delq, delete)
accepts sequences. And contrary to those two, it makes
no guarantees as to how it potentially destroys the original
sequence. So unless you're relying on a particular
implementation, relying on SEQ after calling cl-delete on it
is a bad, bad idea.

So yes, always (setq SEQ (cl-delete THING SEQ)).  With
the extraordinary exception that you're leaving the scope
where SEQ is visible.  Then you can bypass it.

João




This bug report was last modified 6 years and 129 days ago.

Previous Next


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