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, 08 Jan 2019 21:38:17 +0000
Drew Adams <drew.adams <at> oracle.com> writes:

> It's not about implementation of `cl-delete'. It's
> not about the type of sequence you pass it.  It's
> about a variable being something different from its
> value.

Drew, it is you who are missing something basic here:

  (defun mistery (thing seq)
    (let ((head (elt seq 0)))
      (cl-delete thing seq)
      (eq head (elt seq 0))))

Today, in Emacs this always returns t, for every THING and sequence SEQ
you can think of (in fact, for vectors, cl-delete delegates to cl-remove).
This is perfectly CL-compliant.  But a future, different, also perfectly
CL-compliant, implementation of cl-delete, might very well make this
function return nil.  In fact, if you port this code to SBCL or Allegro
CL by changing 'cl-delete' to 'cl:delete'

  (mistery 1 (list 1 2 3 4)) ;; => t
  (mistery 1 (vector 1 2 3 4)) ;; => nil

So again, for the nth time, it's a bad idea to rely on SEQ after calling
'cl-delete'.

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.