From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.bugs Subject: bug#25929: 25.2; map-delete doesn't delete permanently 1st alist elt Date: Sat, 04 Mar 2017 01:04:18 +0100 Message-ID: <87efydlxfh.fsf@drachen> References: <87k288p2oq.fsf@gmail.com> <87k288kkqr.fsf@petton.fr> <87efyfluvi.fsf@petton.fr> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1488585915 23069 195.159.176.226 (4 Mar 2017 00:05:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 4 Mar 2017 00:05:15 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: 25929@debbugs.gnu.org, Nicolas Petton , Tino Calancha To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Mar 04 01:05:10 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cjxC7-00052C-02 for geb-bug-gnu-emacs@m.gmane.org; Sat, 04 Mar 2017 01:05:07 +0100 Original-Received: from localhost ([::1]:32948 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjxCB-0000Gx-Jq for geb-bug-gnu-emacs@m.gmane.org; Fri, 03 Mar 2017 19:05:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58808) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjxC6-0000Fg-4V for bug-gnu-emacs@gnu.org; Fri, 03 Mar 2017 19:05:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cjxC3-0006rk-10 for bug-gnu-emacs@gnu.org; Fri, 03 Mar 2017 19:05:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40739) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cjxC2-0006rg-TX for bug-gnu-emacs@gnu.org; Fri, 03 Mar 2017 19:05:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cjxC2-0006tl-Gg for bug-gnu-emacs@gnu.org; Fri, 03 Mar 2017 19:05:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Michael Heerdegen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 04 Mar 2017 00:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25929 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25929-submit@debbugs.gnu.org id=B25929.148858588626490 (code B ref 25929); Sat, 04 Mar 2017 00:05:02 +0000 Original-Received: (at 25929) by debbugs.gnu.org; 4 Mar 2017 00:04:46 +0000 Original-Received: from localhost ([127.0.0.1]:38938 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cjxBl-0006tB-MK for submit@debbugs.gnu.org; Fri, 03 Mar 2017 19:04:45 -0500 Original-Received: from mout.web.de ([212.227.15.4]:58993) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cjxBj-0006sx-HY for 25929@debbugs.gnu.org; Fri, 03 Mar 2017 19:04:44 -0500 Original-Received: from drachen.dragon ([109.44.2.231]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LyUha-1cFxeF26vW-015qP5; Sat, 04 Mar 2017 01:04:21 +0100 In-Reply-To: (Stefan Monnier's message of "Thu, 02 Mar 2017 10:12:09 -0500") X-Provags-ID: V03:K0:kXpsWLzA/KUlUKKzrq7zcvP0BDv2RtP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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: 208.118.235.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:130137 Archived-At: Stefan Monnier writes: > > (macroexp-let2 nil key > > `(progn > > (map--dispatch ,map > > :list (setf (alist-get ,key ,map nil t) nil) > > :hash-table (remhash ,key ,map) > > :array (and (>= ,key 0) > > (<= ,key (seq-length ,map)) > > (aset ,map ,key nil))) > > ,map))) > > Note that this will make it pretty much impossible to use > cl-generic dispatch. It will also break cases where MAP is an expression that is not a symbol: #+begin_src emacs-lisp (let ((thing (cons 'tag (list (cons 0 1) (cons 2 3))))) (map-delete (cdr thing) 0)) ==> nil (map-delete (list (cons 0 1) (cons 2 3)) 0) ==> if: Symbol's function definition is void: \(setf\ list\) #+end_src > A better option might be to provide a map-remove which works > functionally (i.e. doesn't modify its argument by side-effects), and > then change map-delete to signal an error when we ask to delete the > first element of the list (and to stop returning the "new map" since > it just works imperatively instead). Why not make it just like `delete': return the map with the entry removed, the original map might be altered - that's it. If you want to assign the result back to a symbol/place, use setf or callf. Any unnecessary magic just blows up the semantics. With other words, I would fix this issue by altering the docstring ("return the result" instead of "return MAP") - or am I missing something? Michael.