From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: cl-loop and plists vs alists Date: Mon, 26 Dec 2022 00:11:53 +0000 Message-ID: <87h6xjm3au.fsf_-_@posteo.net> References: <86o7s3lsnx.fsf@mail.linkov.net> <86bknx8783.fsf@mail.linkov.net> <837cylapt4.fsf@gnu.org> <83wn6kamwr.fsf@gnu.org> <83len0aldq.fsf@gnu.org> <83k02kadbv.fsf@gnu.org> <83a63fap35.fsf@gnu.org> <83bknu8tmo.fsf@gnu.org> <18E95AC5-1FFC-4025-B804-7D70DDB1BD75@gmail.com> <87ili1f5vb.fsf@posteo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24037"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Dec 26 01:12:14 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p9b6D-00061I-16 for ged-emacs-devel@m.gmane-mx.org; Mon, 26 Dec 2022 01:12:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p9b60-0004X4-Gn; Sun, 25 Dec 2022 19:12:00 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p9b5y-0004SW-En for emacs-devel@gnu.org; Sun, 25 Dec 2022 19:11:58 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p9b5w-0003Ui-Bj for emacs-devel@gnu.org; Sun, 25 Dec 2022 19:11:58 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 9A942240136 for ; Mon, 26 Dec 2022 01:11:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1672013512; bh=v2HnXBVaP1gofelo3EUjcjWqykUHq4T/NMN4nBu3/nk=; h=From:To:Cc:Subject:Date:From; b=fuydon+4vOkOyyopIhBVfJu5JHGfWyvW+AUOaVigVu3ODH4WKqqEAPkvA6vZMO1FD jXA0PSRModk+6yWRk6LlaaCddgvDrgGgPhsKNTLnm7p97k/I+tbSAOcRaKZCr+FMid LxWysOqpqEQc96YzoGVBy6uDvCOjqo3cJpwCstp1v9i/o8xmDH6TEkX9Kuu1ZtnJPO h2n/hBi6DGh8JNfq5DO8JuRwV1Gwz3EeUJeulLLjQJlBUmASHZSBmG4EIDHx7Sx1D4 2pBR//TYpPDdn2dhBmEVJ0XL0V0lFClYyiVSfHsfL/AHtY0tgQXDlbJSOfqGFapaCE f1AKyrMIuloiw== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4NgJ9x5vVJz9rxD; Mon, 26 Dec 2022 01:11:48 +0100 (CET) In-Reply-To: (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vora=22's?= message of "Sat, 24 Dec 2022 11:01:19 +0000") Received-SPF: pass client-ip=185.67.36.65; envelope-from=philipk@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:301918 Archived-At: (I have removed the remaining CC's because this has nothing to do with the previous discussion, but I'd like to hear if anyone knows more on the topic.) Jo=C3=A3o T=C3=A1vora writes: > On Sat, Dec 24, 2022, 10:33 Philip Kaludercic wrote: > >> . >> >> I would guess a custom function, say `plist-map' along the lines of >> `maphash'. I am kind of surprised to see that this doesn't exist, but >> according to my intuition of property lists, they are not meant to be >> iterated. >> > > Until you step into the real world and you have to. Can you elaborate this point? Is this by intrinsic necessity or due to the "mistakes" of others. Plists are "harder" to iterate, because your steps are cddrs which is an unusual way to run over a data structure. Same applies to adding and removing associations from a plist. The advantage is that they are easier to write. Maybe somebody knows the history here, why and where which of the two were used. Again, my hunch is that going by the respective strengths and weaknesses of the two (in relation to the conventional tools), we can give some heuristic of when it is /better/ to use which of the two. >> While writing this, I also just realise this exists in the "map" >> package. >> >> (map-do (lambda (key val) >> (message "Key %s, Value %s" key val)) >> '(:one 1 :two 2 :three 3)) >> > > Right, a custom function, a loser in versatility (even if this one is > polymorphic, that strength is wasted here) Take your example: print only > three pairs max and a "and more" if there are more than there. I get your point, but this example is geared towards cl-loop. It is powerful as long as you are doing the "right" things. But when you decide to change the problem and say "print only the three pairs with maximal values and a "and more" if there are more than there." then I believe that the language that cl-loop provides isn't elegant anymore.