From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: What's missing in ELisp that makes people want to use cl-lib? Date: Fri, 10 Nov 2023 23:05:25 +0200 Message-ID: <2d8c3047-8c6e-ac03-8ae4-56e73c92f38d@gutov.dev> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25675"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cc: Alan Mackenzie , =?UTF-8?Q?Bj=c3=b6rn_Bidar?= , emacs-devel To: Po Lu , =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Nov 10 22:06:41 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 1r1Yi6-0003NN-FT for ged-emacs-devel@m.gmane-mx.org; Fri, 10 Nov 2023 22:06:39 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r1Yh9-0003uJ-48; Fri, 10 Nov 2023 16:05:39 -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 1r1Yh7-0003tf-Ry for emacs-devel@gnu.org; Fri, 10 Nov 2023 16:05:37 -0500 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r1Yh5-0007qT-GW for emacs-devel@gnu.org; Fri, 10 Nov 2023 16:05:37 -0500 Original-Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailout.nyi.internal (Postfix) with ESMTP id 9353D5C0165; Fri, 10 Nov 2023 16:05:29 -0500 (EST) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Fri, 10 Nov 2023 16:05:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1699650329; x=1699736729; bh=P8Cu7NtY4jyv+npgSKi4V4qp8z4QzGt7ti4 dMw0I+Jo=; b=sDLDhHXLLEF3+ky/bezGMtJxQyCirg3BAj6f3aKovdAsaqqQhKI jr//+G8ISY2vsxGAk9aD04NR4AZf/kRJpOy2qZKLOPES4Wq9bBdNO8mnlW7FdDmV RzUtDsE9M1UauNnDfyfC/Umr1RQzVIgNVtiYgwU6lTru0Vl5WUDieE2Ri0+ArTDY p2d7eBMbCFs1Ij3q2R4t6qlRjW4d1b04/qe8M3JivZpKRuf72wkjWqlxeoOT363w s75QIooQs46k9KVfKJ1lMprzu/HYwRSje4LpjPVjuS2bZM6LIjn/4MeL3x/rFXLn LdlhSnwYcr17ZM2ZiaElRsMNcApcn+WWWpQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1699650329; x=1699736729; bh=P8Cu7NtY4jyv+npgSKi4V4qp8z4QzGt7ti4 dMw0I+Jo=; b=hUUg5UWFA92+6HcBImpOV2SDjVKf2TwsHGRvScgmjvn39heHqDx P88+lZDAnDSYEUzNFN/Mtv58Dx2uxJ2OsUeXyA88bKrv1XbJvqQMx2XYGZRXZt7D CP0M9KPVPqeJUe/+sP+pXSIbuX45UlEa01ahyQGGxrpkUSNDRaOrXTNQkJbgcwlI wSjKSHt+8IXpEH7e9p6614mYd8DtzEBLOQvvlTCtqj9qCINivgGT05FCRLtKcGc2 ZhOlPUXDUbf6+5ia36qx9HAcrMoSUc9TOINV6sFStt6UB8DcPQ49nb3YV1sxv9IN UQZjJz02IdKrMp94RQcSdcsW+JJYte7+1KQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedruddvfedgudegudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefkffggfgfuvfevfhfhjggtgfesthejredttdefjeenucfhrhhomhepffhm ihhtrhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvghvqeenucggtffrrg htthgvrhhnpeeigfetveehveevffehledtueekieeikeeufeegudfgfeeghfdulefgfeev ledvveenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe gumhhithhrhiesghhuthhovhdruggvvh X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 10 Nov 2023 16:05:27 -0500 (EST) Content-Language: en-US In-Reply-To: <87cywhsrcf.fsf@yahoo.com> Received-SPF: pass client-ip=66.111.4.28; envelope-from=dmitry@gutov.dev; helo=out4-smtp.messagingengine.com X-Spam_score_int: -60 X-Spam_score: -6.1 X-Spam_bar: ------ X-Spam_report: (-6.1 / 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, NICE_REPLY_A=-3.265, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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:313513 On 10/11/2023 14:52, Po Lu wrote: > (defun float-to-string (fnum &optional sci) > "Convert the floating point number to a decimal string. > Optional second argument non-nil means use scientific notation." > (let* ((value (fabs fnum)) (sign (< (car fnum) 0)) > (power 0) (result 0) (str "") > (temp 0) (pow10 _f1)) > > (if (f= fnum _f0) > "0" > (if (f>= value _f1) ; find largest power of 10 <= value > (progn ; value >= 1, power is positive > (while (f<= (setq temp (f* pow10 highest-power-of-10)) value) > ............. > (if sign ; if negative, prepend minus sign > (concat "-" str) > str)))) > > If it is to these that you apply the moniker "multi-line raw loop choo > choo trains," then they are precisely what should be written more, not > less. I don't have the corresponding high-level implementation to compare to, but the main thing about the code you posted, is that one has to, basically, read every line (of which there are ~70) to understand what the function is doing and/or to find any irregularities in its implementation (e.g. when looking for a bug). > The "Lisp way" (more felicitously the cl-lib way) is to provide > functions to truckloads of other functions which interface them with one > another. A high-level approach is to use a set of agreed-upon abstractions (functional programming in general, across languages, has a basic set, but there can be additions) to write programs shorter. > Each such function is a unique control construct. To glean what a > function does, one must not only commit each of these control constructs > to memory, but as is all too often the case when the functions provided > to the control constructs are beyond its control, also examine each of > its callers, with labyrinths that put C++ to shame into the bargain, > like pcase-lambda and macros which rewrite the control flow of a form > beyond recognition. There is, indeed, a mental cost to understanding the code which uses them -- one has to know the abstractions and be able to connect the names with the concepts. There aren't too many of them in use, though. We can argue whether cl-lib is an optimal set, or could be reduced (there are indeed many functions and macros in there that I never saw the point of using). But your proposed goal (full eventual removal of cl-lib, or anything like it) is a non-starter from my POV.