From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.bugs Subject: bug#34708: alist-get has unclear documentation Date: Mon, 11 Mar 2019 17:19:51 +0100 Message-ID: <87wol5l6xk.fsf@web.de> References: <87wolhr5k6.fsf@web.de> <87y35xdu4w.fsf@web.de> <87mumcdu7f.fsf@web.de> <875zsyhakx.fsf@ericabrahamsen.net> <87fts2h9we.fsf@web.de> <871s3mh85d.fsf@ericabrahamsen.net> <874l8iebyz.fsf@web.de> <878sxui7bo.fsf@ericabrahamsen.net> <87va0xcxco.fsf@web.de> <87h8chey12.fsf@ericabrahamsen.net> <60367f47-c0b0-45b4-8ccf-169044400a75@default> <8736ntmsy3.fsf@web.de> <3af3b645-84e0-4208-be48-810e8cd2cfa8@default> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="241538"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Eric Abrahamsen , 34708@debbugs.gnu.org To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Mar 11 17:22:58 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 esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h3NhY-0010ay-A5 for geb-bug-gnu-emacs@m.gmane.org; Mon, 11 Mar 2019 17:22:56 +0100 Original-Received: from localhost ([127.0.0.1]:36438 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3NhX-0002Gu-8q for geb-bug-gnu-emacs@m.gmane.org; Mon, 11 Mar 2019 12:22:55 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:53357) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3Nfn-0001Ct-27 for bug-gnu-emacs@gnu.org; Mon, 11 Mar 2019 12:21:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3Nfl-0001yQ-1R for bug-gnu-emacs@gnu.org; Mon, 11 Mar 2019 12:21:07 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54087) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h3Nfk-0001xv-M5 for bug-gnu-emacs@gnu.org; Mon, 11 Mar 2019 12:21:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h3Nfh-0004Q3-Tb for bug-gnu-emacs@gnu.org; Mon, 11 Mar 2019 12:21:04 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Heerdegen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 11 Mar 2019 16:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34708 X-GNU-PR-Package: emacs Original-Received: via spool by 34708-submit@debbugs.gnu.org id=B34708.155232121316905 (code B ref 34708); Mon, 11 Mar 2019 16:21:01 +0000 Original-Received: (at 34708) by debbugs.gnu.org; 11 Mar 2019 16:20:13 +0000 Original-Received: from localhost ([127.0.0.1]:39398 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h3Nev-0004Oa-8d for submit@debbugs.gnu.org; Mon, 11 Mar 2019 12:20:13 -0400 Original-Received: from mout.web.de ([212.227.17.12]:43171) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h3Net-0004OL-Sa for 34708@debbugs.gnu.org; Mon, 11 Mar 2019 12:20:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1552321193; bh=xTEB9O715RbHRFt8gFVmM1aggT15+lONyK5nE7aC15k=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=PSgiHnpkkTEsDn9vr/hpM0/R7CtrRKq0h+/T4kljdmGmr6tIFHzotXxCoi/xBeFNS vLX9s7aIHMxNncOgsyrx1riXkpLAJ0ubGypoj9Ay0d1LTwWHSmju5cpJz62arFyOFJ ylTEEyhDGpQ8og8oDzfpEIDTocX9kwbVQI20kJzE= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Original-Received: from drachen.dragon ([88.67.111.211]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0LrJwm-1gvdrQ38KC-0137nl; Mon, 11 Mar 2019 17:19:52 +0100 In-Reply-To: <3af3b645-84e0-4208-be48-810e8cd2cfa8@default> (Drew Adams's message of "Mon, 11 Mar 2019 07:52:31 -0700 (PDT)") X-Provags-ID: V03:K1:I+i5/d8UWqNE3QJ8ezz5LA7vyhYXyN/gWJdD0v6Ou2jUFWxJlDZ eRUX26RH7OESh4/tWPzS1RcZNJ+R2jjmLDGQelsYjYFWfxaClUsO3ndnl1rV3y8kRyy0pSG WO33S+biZbxa0LhltK0ISsp24e8ZqY+CCgDv4Em95zZ81X9fHdMlGgzBrcX6y0CWFN/qXKr JREOELTaiurD8kCTPnbOA== X-UI-Out-Filterresults: notjunk:1;V03:K0:T6hVbC42VYk=:kA/HXUpqPSbM6SRpxeffYq 86gMXuzpneVs6v3p9hqPVWN0nUKm8RpfqJ8eUT4g6TELP87FM3YyWTPZCzwYe5MnO822lI7c8 NQE9KPujCMg6rtTjpqBiJqCxC5LjmphVLP6hyaCE+9DCsjvAhMz/kpNXShmAmtGfHiBMwtgO1 smy0p+QaGS7+3VcbWHcrEkE0xuyUaBzXJ9WVF5EaVy7JDDwIihWtGDWn/8nwdJCYna7J7AHds tNLaFIcVJMyTBcKh2vDx+WcxXzyu3VfBp4CtRjAkRgqib5wgsgzUwe38C3K7+mewWGtuchHis JE0eUJrlpFo3mi+Ilbqae3UmYEPT5VBGCcPtIZI9Pqf03QZoBRlZ65vlsBeF/jKyx2WAgu46s 0y0bq5lTALpLHRxUPjdrxRl/+F7pQ9GbsiqwFQ/GV9XEXTRwFGDckurvz8oQfVaE0SU78+Y5n 25Y1v8yhmuESL7xA7Sky1A5Kh4mjiMwVUvM/oKxMOMBfFisGxlswu18iE7On6ZgaiVysY+gaJ ZFgVGCmMst/Owvvtk59i2mEJ6OqDi//WM+ylCprAdSzwcwzR6Lxmg9EGqQqoHNATwQJUt2uqF 2EcqlCdQi+K84bjkxV77R0zsZNvEovt3tg/Auv9vrKXwIMqpd1qkA/YuqKrwyVVXt9TRzDeaN B6IxZ7S8FOfZp/R98ORVp4niwuY1sDIaPQHkfWQ75iQEZ3XLQUFo8QZ3kkXMw7v1F3yip5ZYV 9CvLEyPZ83V0nK2bYl1Ok225qK4sVW1wXnrM2jKGUFduz2mRii2hC+YlI1+hnyt7/b1RcD53 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:156239 Archived-At: Drew Adams writes: > > (1) "When using it to set a value, optional argument REMOVE non-nil > > means to remove KEY from ALIST if the new value is `eql' to DEFAULT." > > > > I wonder if there are use cases where the user wants something differe= nt > > than `eql'? E.g. `equal' when the associations are strings? Note tha= t > > this is something different than TESTFN which is for comparing keys. > > I think so, yes. Why wouldn't we want to allow that? To not add one more argument? If we do that, I guess I would rather allow that the non-nil value of REMOVE is allowed to be a function. A related use case would be to allow to delete the association of a key independently from associated value. > > (2) The remove feature has a strange corner case. Normally the > > first found association is removed, > > So "normally" it's really "remove one". > > Why is this? What's the point of REMOVE - why is > it needed (added to the design) at all? Is it to > provide a way to remove all entries with a given > key or only the first such? The first. > If we want to provide for pretty much everything > that one typically does with an alist (without > `alist-get') then don't we need to provide for the > ability to do any kind of removal - or other > operations - on alist elements that have a given key? > > Should "set" and "remove" operations not (at least > be able to) obtain the _full_ sequence (in entry > order) of such matching elements, and then perform > specific operations on that sequence (such as setting > or removing the first one, the Nth one, or all of > them)? > > If we were not trying to allow `alist-get' to be > usable as a generalized variable then I suppose > we wouldn't need to worry about any of this. We tried. I think the result should be consistent and convenient, but we don't need to implement all realizations of all operations for the generalized variable. One thing I don't find consistent is the case where the alist already has multiple occurrences of a key. E.g. (setq my-alist '((a . 1) (b . 2) (a . -1))) (setf (alist-get 'a my-alist 1 'remove) 1) my-alist =3D=3D> ((b . 2) (a . -1)) (alist-get 'a my-alist 1) =3D=3D> -1 (!) One would expect 1, of course. > It would be good to see a statement/spec of what > `alist-get' is trying to accomplish, especially > wrt setting, testing (diff predicates), and > removing. Yes, this is what my patch will try to accomplish. Michael.