From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: What's missing in ELisp that makes people want to use cl-lib? Date: Sun, 12 Nov 2023 08:45:06 +0200 Message-ID: <83leb3v5al.fsf@gnu.org> References: <871qd8sfdx.fsf@posteo.net> <838r7g8pys.fsf@gnu.org> <87bkcbrgnr.fsf@posteo.net> <25924.21015.19614.951576@orion.rgrjr.com> <87bkc4jpja.fsf@dataswamp.org> <12da6bcb-1818-7fbe-12af-8d4607724332@gutov.dev> <87il6bt4z0.fsf@yahoo.com> <8734xetjkk.fsf@yahoo.com> <87cywhsrcf.fsf@yahoo.com> <87cywgx1z0.fsf@web.de> <83wmuowwp3.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29705"; mail-complaints-to="usenet@ciao.gmane.io" Cc: joaotavora@gmail.com, emacs-devel@gnu.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 12 07:46:50 2023 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 1r24F7-0007Xx-JW for ged-emacs-devel@m.gmane-mx.org; Sun, 12 Nov 2023 07:46:49 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r24EK-0003ry-O8; Sun, 12 Nov 2023 01:46: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 1r24EH-0003qQ-OH for emacs-devel@gnu.org; Sun, 12 Nov 2023 01:45:57 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r24EG-0002Aj-WF; Sun, 12 Nov 2023 01:45:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=XMSJEUpo3NzyA1AUA0avgzbKKfCEIT4oVbOEyxN1yZg=; b=SwbkZl9458bk iJkPJuR/Zgv1MEbeAbsN+uSHrxTo+bUjY5KohWHw8+W3/Y78c6qObYk2yVzSaC2+R6shndvznFgV9 JlOXsf9EYigSgfu38s7yXYgQd3gwGBwUdyvw45HmwVshnWn8FdmDmd0wU8QDAdw8DgKvbulMPzOpr VDp7tKyFaFiR6dGnjmO0er2gureQHnGvDprecRCzaSlZzYqymQ1otkSi73Iv3yL/u9zpSAhQiEf2I iNNjmC4pZ2JtxeYpcLXnJEu7gJktdQVIr+ZClJe1LbGI7Hku20h+DYG9l/OZxEgGaAbWou3vH9O0b eCxD+iWgdIAq0FXUZbWRfg==; In-Reply-To: (message from Richard Stallman on Sat, 11 Nov 2023 21:57:02 -0500) 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:312636 Archived-At: > From: Richard Stallman > Cc: emacs-devel@gnu.org > Date: Sat, 11 Nov 2023 21:57:02 -0500 > > > But when you need to process plists, for example, it becomes > > very handy. This construct, which does require knowing a bit > > of the mini-language that is cl-loop, > > > (cl-loop for (k v) on plist by #'cddr collect (cons k v)) > > It is certainly concise. If I saw that code I would not understand it, > but if you said what job it does I could see how it might do that. > > That's because cl-loop defines its own little language, which I don't know. Btw, the above is a very simple use of cl-loop. We have quite a few of much more complex ones. For example: (cl-loop with comp-ctxt = (make-comp-cstr-ctxt) with h = (make-hash-table :test #'eq) for (f type-spec) in comp-known-type-specifiers for cstr = (comp-type-spec-to-cstr type-spec) do (puthash f cstr h) finally return h) or this: (cl-loop for i = 0 then (+ i (if (eq (nth i list) ?\\) 4 1)) for var = (nth i list) while (< i size) if (eq var ?\\) collect (string-to-number (concat (cl-subseq list (+ i 1) (+ i 4))) 8) else collect var)) or this: (cl-loop named loop with above for lane in (comp-cstr-ctxt-typeof-types comp-ctxt) do (let ((x (memq type lane))) (cond ((null x) nil) ((eq x lane) (cl-return-from loop x)) ;A base type: easy case. (t (setq above (if above (comp--intersection x above) x))))) finally return above)) It isn't an accident that the reference documentation of cl-loop in cl.info takes a whopping 700(!) lines.