From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Deus Max Newsgroups: gmane.emacs.bugs Subject: bug#33998: 27.0.50; cl-delete does not delete the first list element Date: Mon, 07 Jan 2019 22:20:55 +0200 Message-ID: <877efgte1k.fsf@aia00054aia.gr> References: <87muodud4d.fsf@aia00054aia.gr> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1546892406 1529 195.159.176.226 (7 Jan 2019 20:20:06 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 7 Jan 2019 20:20:06 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 33998@debbugs.gnu.org To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= , Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jan 07 21:20:01 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ggbNR-0000II-8m for geb-bug-gnu-emacs@m.gmane.org; Mon, 07 Jan 2019 21:20:01 +0100 Original-Received: from localhost ([127.0.0.1]:44115 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggbPX-0001cp-Pz for geb-bug-gnu-emacs@m.gmane.org; Mon, 07 Jan 2019 15:22:11 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:52583) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggbPQ-0001bU-DX for bug-gnu-emacs@gnu.org; Mon, 07 Jan 2019 15:22:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggbPO-0001EK-E1 for bug-gnu-emacs@gnu.org; Mon, 07 Jan 2019 15:22:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49697) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ggbPO-0001Cc-8v for bug-gnu-emacs@gnu.org; Mon, 07 Jan 2019 15:22:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ggbPN-0006AF-VE for bug-gnu-emacs@gnu.org; Mon, 07 Jan 2019 15:22:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Deus Max Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 07 Jan 2019 20:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33998 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 33998-submit@debbugs.gnu.org id=B33998.154689247123633 (code B ref 33998); Mon, 07 Jan 2019 20:22:01 +0000 Original-Received: (at 33998) by debbugs.gnu.org; 7 Jan 2019 20:21:11 +0000 Original-Received: from localhost ([127.0.0.1]:48978 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ggbOZ-000696-4o for submit@debbugs.gnu.org; Mon, 07 Jan 2019 15:21:11 -0500 Original-Received: from mout.gmx.net ([212.227.17.20]:37295) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ggbOY-00068r-0U for 33998@debbugs.gnu.org; Mon, 07 Jan 2019 15:21:10 -0500 Original-Received: from dellcorei5dias ([5.55.202.130]) by mail.gmx.com (mrgmx103 [212.227.17.174]) with ESMTPSA (Nemesis) id 0M1FAK-1hZXQQ1yWW-00tCwb; Mon, 07 Jan 2019 21:20:58 +0100 In-Reply-To: ("=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?="'s message of "Mon, 7 J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2Akmqp1QzKsgEO+vU7qmfSl6wdUzRi0wTRD2M5kISHbL3j8WoS X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:154230 Archived-At: Thank you both for your replies. On Mon, Jan 07 2019, Jo=C3=A3o T=C3=A1vora wrote: > There is no bug. > > You should always read "destructive" as "potentially > destructive". > I believe the manual is precise and not up to interpretation. When it says that it is "destructive", it is always "destructive". The cl-delete function is always destructive. The variable you pass is modified. > 'cl-delete', being a function, cannot know that the value > you passed it is pointed to by the symbol 'tst'. Or, in lisp > speak, that that value is the variable binding of 'tst'. > > Because it doesn't know this, it cannot affect the variable > binding of 'tst', to be '(cdr tst)', which would be the only > way to do what you want (remove the first element). > > If 'cl-delete' were a macro, like 'pop' is, it could do that > (but that would have other disadvantages). > > So, cumbersome as it is, you should always use: > > (setq seq (cl-delete thing seq )) > > The docstring of 'delq' has this explanation more or less: > > delq is a built-in function in `C source code'. > > (delq ELT LIST) > > Delete members of LIST which are `eq' to ELT, and return the result. > More precisely, this function skips any members `eq' to ELT at the > front of LIST, then removes members `eq' to ELT from the remaining > sublist by modifying its list structure, then returns the resulting > list. > > Write `(setq foo (delq element foo))' to be sure of correctly changing > the value of a list `foo'. See also `remq', which does not modify the > argument. > > Jo=C3=A3o > The elisp functions `delq' and delete "destructive" as per manual remove elements from a list and return the resulting list. It goes on to recommend to always use the `(setq foo (delq elm foo))' construct. OK, I agree, no argument here. But my point is about function `cl-delete', which is part of the cl-extension. So, the manual descriptions of `delq', `delete' do not apply. In cl: - to keep the original sequence intact, use `cl-remove'. - to modify the original sequence, use `cl-delete'. The manual states for `cl-delete': This deletes all elements of seq that match item. It is a destructive operation. (period, no optional) It goes on to remark, on the analogy between `cl-remove' and `cl-delete': Compare append and nconc, which are analogous non-destructive and destructive list operations in Emacs Lisp. I still thing it is a bug. It (`cl-delete') should delete *all* elements of seq, that match item, not = only in the returning value, but in the sequence itself. Anyway, that is how it behaves in all other cases, except for the case of a match on the *first* element. I don't see why the first element should be different. The manual makes no mention of this as a special (and peculiar) case. > > > > > On Sun, Jan 6, 2019 at 5:48 PM Deus Max wrote: >> >> >> Function cl-delete refuses to delete the first element of a list. >> I tried with all sorts of list elements, same results each time. >> Here is a simple example: >> >> (setq tst '(5 8 9 5 10 14 5 23)) >> >> (cl-delete 10 tst) -> returns (5 8 9 5 14 5 23) >> and >> tst -> (5 8 9 5 14 5 23) >> >> (cl-delete 5 tst) -> returns (8 9 14 23) >> but >> tst -> (5 8 9 14 23) *** Wrong ! should be the same to the returned value. >> >> The CL-manual says nothing about the first element being special. *ALL* >> should mean all, right ? Am I missing something here ? >> >> CL-manual says: >> =E2=80=94 Function: cl-delete item seq &key :test :test-not :key :count = :start :end > :from-end >> >> This deletes all elements of seq that match item. It is a >> destructive operation. Since Emacs Lisp does not support >> stretchable strings or vectors, this is the same as cl-remove for >> those sequence types. On lists, cl-remove will copy the list if >> necessary to preserve the original list, whereas cl-delete will >> splice out parts of the argument list. Compare append and nconc, >> which are analogous non-destructive and destructive list >> operations in Emacs Lisp. >> DeusMax