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: Wed, 15 Nov 2023 03:28:40 +0200 Message-ID: <1e7fe1ef-af7d-3222-7b9e-b569b3c97ccf@gutov.dev> References: <87cywhsrcf.fsf@yahoo.com> <87cywgx1z0.fsf@web.de> <83wmuowwp3.fsf@gnu.org> <8334xcwank.fsf@gnu.org> <320999cc-6c83-2315-0044-cc0403400af3@gutov.dev> <9ab5d2bd-a648-cae0-a4a7-ae86be10af0f@gutov.dev> <87r0kuqxbf.fsf@gmail.com> <54e115a2-fc36-3056-a030-0dbf32416ddb@gutov.dev> <43f290b0-4119-597b-c89a-0fb4c7db1665@gutov.dev> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14698"; 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: =?UTF-8?Q?Gerd_M=c3=b6llmann?= , Eli Zaretskii , michael_heerdegen@web.de, emacs-devel@gnu.org To: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Nov 15 02:29:39 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 1r34in-0003Xh-Ai for ged-emacs-devel@m.gmane-mx.org; Wed, 15 Nov 2023 02:29:38 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r34i2-0005Jq-2J; Tue, 14 Nov 2023 20:28:50 -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 1r34i0-0005JL-5k for emacs-devel@gnu.org; Tue, 14 Nov 2023 20:28:48 -0500 Original-Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r34hx-0003pj-MZ; Tue, 14 Nov 2023 20:28:47 -0500 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 666B65C01C1; Tue, 14 Nov 2023 20:28:44 -0500 (EST) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 14 Nov 2023 20:28:44 -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= 1700011724; x=1700098124; bh=zxwVo+naZES40Rvv2tPlKkRcAAJq0DLvpnw ncDuQOdI=; b=bRGkA80l0kqceTplzvC0xlvZRk8BNJMavg/5s/sZw1g/KmB6R3Y phcXcFW6zyK3JTAMwwd5WUTGjmnm2jZUjy+0Z5SMSGmLfARKI/UW+448BaHdhNs7 /KREmSuMdbTNIN5HfEs1Yw6IIuQfLNDHtQG+SC22JKJn0NiYO6yhp14lvDEA5yi4 yAbek3VZKXbWmaitZlCDq6wNJN78+hrj88lClKRrPsvVzfYGPsbnmgTjDFpcMjdv PBfVcIhBI8msiBexOwwTPJcVspRNqo+aKi5S+oOYXgCBOhNRZLsIchWCA2/WE6JG NpXBOqwaC8gq2MQ4MWnhqczr6cALj/kmKog== 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=fm1; t= 1700011724; x=1700098124; bh=zxwVo+naZES40Rvv2tPlKkRcAAJq0DLvpnw ncDuQOdI=; b=ozhGF2NL/9O9PtJDqj3ueXigaJi+20mZDBfqUjNnkoR9nbrQuqy UjWqXu7xjjX35atEYxBAjlIx4aOPFftV1YOxsfDZt8POf1JP5LhEAZckymj3sWzz +TIDNbnBWGsLO/IE3O9F3AzI3Ic3DnJYxnY/BCOHkHYPrVlBYT8vbRnhVhtMsgv2 RrQ8z74THl37MxFM7qIqSAPjQ1QGSdAUkHQ00COkgFUamDEAQI7LLsbUqjG/oG3t rb0uPTLlG4AWejlK4wC40jre14FF3p1B935rrIilQMnBmqGTy/o/2bHpTZDInrWI Ls1IlIV8RwbmQI6GFqYJt5v+DnJxDEZYTsg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudefgedgfeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtfeejnecuhfhrohhmpeffmhhi thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth htvghrnhephfffheeljeffgeffueeghfekkedtfffgheejvdegjeettdduheeufffggfef jeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepug hmihhtrhihsehguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 14 Nov 2023 20:28:42 -0500 (EST) Content-Language: en-US In-Reply-To: Received-SPF: pass client-ip=66.111.4.29; envelope-from=dmitry@gutov.dev; helo=out5-smtp.messagingengine.com X-Spam_score_int: -64 X-Spam_score: -6.5 X-Spam_bar: ------ X-Spam_report: (-6.5 / 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.695, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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:312748 Archived-At: On 15/11/2023 03:07, João Távora wrote: > On Wed, Nov 15, 2023 at 12:46 AM Dmitry Gutov wrote: > >> Then it must have a seq-do implementation that yields :secret-voodoo one >> or several times. > > Not really. Only if I use my seq in contexts where I need that > generic, and being second argument to seq-difference doesn't count. > So why should I bother implementing that when my code is working > fine today? Commentary at the top of seq.el says: ;; seq.el can be extended to support new type of sequences. Here are ;; the generic functions that must be implemented by new seq types: ;; - `seq-elt' ;; - `seq-length' ;; - `seq-do' ;; - `seqp' ;; - `seq-subseq' ;; - `seq-into-sequence' ;; - `seq-copy' ;; - `seq-into' > But say I did that seq-do, then what is the seq-contains-p generic good > for then? Why some many redundant generics that the user learns the > hard way have to be consistent with each other? So any new type gets a lot of functions implemented very easily, and could add specialized implementations for performance. >> And then the seq-contains-pred implementation will do >> right by it (the default one, not the specialization for lists). >> >>>> This is not documented, >>> >>> You don't say? :-) i think we should get started on documenting all >>> these ad-hoc rules (sorry but in this case they are quite literally >>> ad-hoc). Better than nothing, I guess, since as to actually enforcing >>> them, I think that train has left the station a long time ago and is >>> now in a voodoo swamp in monkey island. >> >> Not sure "enforcing them" is the right phrase: I wonder if there's ever >> been a change proposed to seq.el which would break them. > > I think it's pretty easy to do, especially if these optimziations > want going to go all the way to cl-lib's easier-to-get optimal > performance. What about this? Is this toy implementation of > compressed space-saving lists legal? > > (cl-defmethod seq-do (function (l (head :m6-sparse))) > (mapc (lambda (e) > (if (eq e :double-o-seven) > (progn (funcall function 0) > (funcall function 0) > (funcall function 7)) > (funcall function e))) > (cdr l))) > > (cl-defmethod seq-reverse ((l (head :m6-sparse))) > (let (res) > (seq-do (lambda (e) (push e res)) l) > res)) > > (seq-difference '(:m6-sparse 1 2 :double-o-seven 4) '(7)) ;; => (1 2 0 0 4) > > Again, not implementing all the generics, just the ones I need > to get my desired effect, which in this case is passing a > custom sequence type as a first argument to seq-difference. Very clever. I'm not thinking too well this time of night, but the first part of the reply in this email probably answers the question (there is a certain set of generics that must be implemeneted).