From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#25929: 25.2; map-delete doesn't delete permanently 1st alist elt Date: Thu, 2 Mar 2017 20:30:35 +0900 (JST) Message-ID: References: <87k288p2oq.fsf@gmail.com> <87k288kkqr.fsf@petton.fr> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="8323329-1648407496-1488454237=:30755" X-Trace: blaine.gmane.org 1488454278 6362 195.159.176.226 (2 Mar 2017 11:31:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 2 Mar 2017 11:31:18 +0000 (UTC) User-Agent: Alpine 2.20 (DEB 67 2015-01-07) Cc: 25929@debbugs.gnu.org, Stefan Monnier , Tino Calancha To: Nicolas Petton Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Mar 02 12:31:13 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 1cjOwv-0000j3-Ql for geb-bug-gnu-emacs@m.gmane.org; Thu, 02 Mar 2017 12:31:10 +0100 Original-Received: from localhost ([::1]:51670 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjOx1-0001YM-Qj for geb-bug-gnu-emacs@m.gmane.org; Thu, 02 Mar 2017 06:31:15 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39037) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjOwu-0001XJ-0L for bug-gnu-emacs@gnu.org; Thu, 02 Mar 2017 06:31:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cjOwp-0005Hc-07 for bug-gnu-emacs@gnu.org; Thu, 02 Mar 2017 06:31:08 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37205) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cjOwo-0005HO-Si for bug-gnu-emacs@gnu.org; Thu, 02 Mar 2017 06:31:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cjOwo-0007Xa-Gy for bug-gnu-emacs@gnu.org; Thu, 02 Mar 2017 06:31:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 02 Mar 2017 11:31: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.148845424828965 (code B ref 25929); Thu, 02 Mar 2017 11:31:02 +0000 Original-Received: (at 25929) by debbugs.gnu.org; 2 Mar 2017 11:30:48 +0000 Original-Received: from localhost ([127.0.0.1]:35404 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cjOwa-0007X6-2K for submit@debbugs.gnu.org; Thu, 02 Mar 2017 06:30:48 -0500 Original-Received: from mail-pf0-f193.google.com ([209.85.192.193]:34368) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cjOwW-0007Wr-GI for 25929@debbugs.gnu.org; Thu, 02 Mar 2017 06:30:46 -0500 Original-Received: by mail-pf0-f193.google.com with SMTP id x66so6523660pfb.1 for <25929@debbugs.gnu.org>; Thu, 02 Mar 2017 03:30:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=qdJpgvz3UYI7FH5qj8Q5XSqym8YZAHBIS+EE2b/B+j8=; b=b+qEFWoHPCdOHodRNK5PoQcsDDQRMHBKoz0mCnYe/MZRGMsBa7sFAhmO68bJsyMvtd TWBUGYodUW7L0E38EWD/hq8xNF1LInm2QuC+HmonM8M5rxjAU39bljL5DqYmD6in33+M PrNK8jfWzY4wrgD9GW1Lmu9CoQQoG1ZgTFE4SLjFijnM6VLmj0VHYk+PEMVLmbz1fxDu jN8Q6B0x1TO7jtyal6uqBbG55mLo/B/5OQnIIJqxLBjY6805wl+oD4pfkCfDflDWEY96 OzjuiaCU8ECoJD9ZduyeGJeeFBBpcaNIenFsP0+ChLLk37Arw86YyKHTX93xdIsgNsEW NE7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=qdJpgvz3UYI7FH5qj8Q5XSqym8YZAHBIS+EE2b/B+j8=; b=nRi+I5S9yvY4looTW6SZh2U/tCT2xiMEetyL3MaQsZmH21aQETqII5uSU2QcmM6Ux0 +zjb0XWilpVwqHWWo1p1vZTCbdtavZOhqMZXBRlG0KJK6nFkjD3vbR0Trjm2rgF96tMQ kWLLb7gwd5WFWSE45K1xNY4PAMAlGlZo8xHZMTmV7YMWCkcoDMEpchwdxDJJ7xgzcRUK WjR5gyR62SUOzsxNYMqeKiehTl83Asm8rrOZzSdbHRa8Jm1lCqHogU3fZe7YzvK65tGQ EtiQKt8t+HIShm5XV0unibu5Cwd2ZLpKU1Eq6fmTFESeLMOjCOV9/RvJorB/yY6c04Tx GA1A== X-Gm-Message-State: AMke39kxFBy0YgFXKucbZ4I99kNoAtlY1YnPEF07imr5IG6SCXDtUwm0PEw9mGbNkBpFsQ== X-Received: by 10.99.150.10 with SMTP id c10mr14984854pge.160.1488454238770; Thu, 02 Mar 2017 03:30:38 -0800 (PST) Original-Received: from calancha-pc (104.81.147.124.dy.bbexcite.jp. [124.147.81.104]) by smtp.gmail.com with ESMTPSA id m12sm16649307pgc.46.2017.03.02.03.30.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Mar 2017 03:30:38 -0800 (PST) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc In-Reply-To: <87k288kkqr.fsf@petton.fr> 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: 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:130042 Archived-At: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1648407496-1488454237=:30755 Content-Type: text/plain; format=flowed; charset=ISO-8859-7 Content-Transfer-Encoding: 8BIT On Thu, 2 Mar 2017, Nicolas Petton wrote: > Tino Calancha writes: > > >> (cl-loop for i below 3 collect >> (let ((map (list (cons 0 3) >> (cons 1 4) >> (cons 2 5)))) >> (map-delete map i) >> (null (map-elt map i)))) >> => (nil t t) ; The first pair, i.e. '(0 . 3) is not permanently deleted. > > The alist is indeed modified within the `map-delete' function, but in an > unexpected way: if the first key is deleted, the variable `map' is > `setq'ed, which has no effect outside of the function. > > One fix would be to make `map-delete' a macro: > > (defmacro map-delete (map key) > "Delete KEY from MAP and return MAP. > No error is signaled if KEY is not a key of MAP. If MAP is an > array, store nil at the index KEY. > > MAP can be a list, hash-table or array." > `(macroexp-let2 nil key > (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)) > After this patch if i run the above recipe i get an error: let*: Symbol¢s function definition is void: map--dispatch --8323329-1648407496-1488454237=:30755--