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


Message #32 received at 33998 <at> debbugs.gnu.org (full text, mbox):

From: Deus Max <deusmax <at> gmx.com>
To: João Távora <joaotavora <at> gmail.com>
Cc: 33998 <at> debbugs.gnu.org, Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#33998: 27.0.50;
 cl-delete does not delete the first list element
Date: Tue, 08 Jan 2019 00:46:28 +0200
On Mon, Jan 07 2019, João Távora wrote:

> Emacs's cl-delete attempts to emulate Common Lisp's CL:DELETE.  In Emacs
> it behaves, in this regard, no different from delete or delq.  It is
> "potentially destructive" because it *may* modify the *structure* of the
> sequence *value* that you pass to it, be it a linked list or a vector:
>
> 1) If it is a linked list, it does the trick of making the pointer
>    before the element you want to delete point to the element after it;
>
> 2) If it is a vector, it moves all the vector elements after the one you
>    want to delete back one position and readjusts the vector size.
>
> If you notice, for situation 2 you could theoretically affect the
> variable binding directly.  And curiously, this is where I found
> differences between Emacs's cl-delete and some CL's implementation of
> CL:DELETE.
>
> Emacs:
>
>     (setq bla (vector 1 2 3 4))
>     (delete 1 bla) => [2 3 4]
>     bla => [1 2 3 4]
>      
>     (setq bla (vector 1 2 3 4))
>     (cl-delete 1 bla) => [2 3 4]
>     bla => [1 2 3 4]
>
> Allegro common lisp and CMU common lisp:
>
>    (setq bla (vector 1 2 3 4))
>    (delete 1 bla) => #(2 3 4) 
>    bla => #(2 3 4)
>
> SBCL common lisp:
>
>    (setq bla (vector 1 2 3 4))
>    (delete 1 bla) => #(2 3 4)
>    bla => #(2 3 4 4)
>
> So, for vector sequences, CL:DELETE is apparently allowed to do
> whatever.  Reading the hyperspec, it seems that all these results are
> correct, even SBCL's.
>
> João

Wow! thanks for clarifying the points.
I had to fire up my SBCL to see it !





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

Previous Next


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