From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: Code for cond* Date: Wed, 28 Feb 2024 22:50:30 -0500 Message-ID: References: Reply-To: rms@gnu.org Content-Type: text/plain; charset=Utf-8 Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15951"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Feb 29 04:51:25 2024 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 1rfXS9-0003vs-DM for ged-emacs-devel@m.gmane-mx.org; Thu, 29 Feb 2024 04:51:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfXRK-0005Lr-Lx; Wed, 28 Feb 2024 22:50:34 -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 1rfXRI-0005KS-O6 for emacs-devel@gnu.org; Wed, 28 Feb 2024 22:50:32 -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 1rfXRH-0005fL-PQ; Wed, 28 Feb 2024 22:50:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=Date:References:Subject:In-Reply-To:To:From: mime-version; bh=wr6aGNiyPDKQAtbowcnVtItOnpcm1DFh138IpkJWuwg=; b=fKiKdEpEYOvL hIYN5DNssz2bh9UlrM6QYpN+/TXq1rdWB+EprGJhedOkrS6XJEicpl25WvjNibt09clfTptI9ek6n 87bPuD0ZlH9hSSpvEsN/jd/5hHE+LUvFFMqFOqhaI900XB+iool4wz5QhNjBriZN/1eJUoQJ/f5cW 6rIJTQnXteN3/mwyK14sO88iJwC9e0tfAhNe4/1a33pHC0CJdJMHgow/R4E6zxLmuR9JdHsJ4GcZP I9FHFyiob94jlgN4tVDmgRoHa9n13YVyB+Bwut2Zo+klKCeO6XikHgpEdoRcAs3Kl35TJwW+98InQ H9Aym7xL64aTefSFUNz5qA==; Original-Received: from rms by fencepost.gnu.org with local (Exim 4.90_1) (envelope-from ) id 1rfXRG-0002lt-SO; Wed, 28 Feb 2024 22:50:31 -0500 In-Reply-To: (message from Stefan Monnier on Sun, 25 Feb 2024 10:03:48 -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:316633 Archived-At: [[[ To any NSA and FBI agents reading my email: please consider ]]] [[[ whether defending the US Constitution against all enemies, ]]] [[[ foreign or domestic, requires you to follow Snowden's example. ]]] > - Which example was that? Have you found many others? Sorry, I don't seem to have a copy of it I can find. I looked for it in my mail archive about this issue but did not see it. Mayne what I was sent was function names and I looked at them in the source code. I think someoene sent me a list of examples, in December perhaps, to show me how pcase is often used. Naybe the items in that list were function names, which would explain why I can't search for that email. > - What do you reply to my own experience that we often want to accept > not only longer lists but also shorter lists? Maybe you are right, but I don't think I have seen an example of it. Hmm, was this the purpose of proposing the cl-lambda pattern operator? I agree it could make sense to combine these wo features ino one, if there is a clean way to do it There oould be two flags: * Ignore excess list elements. That is what I implemented as (cdr-safe ...). * Accept shorter lists. That could be called (truncate-ok ...). (truncate-ok `(foo ,a ,b)) would match (foo lose quux) or (foo lose) or just (foo). These two flags are opposutes in spirit, but they do not conflict; it would make sense to set both flags at once. (cdr-safe (truncate-ok `(foo ,a ,b))) Another possible approach is to specify minimum and maximum list length for the data to be matched. (list-length 1 nil `(foo ,a ,b)) where nil means "no maximum length". However, we would not want `list-length' to affect sublists. Nor '`truncate-ok'. Basically, I think allowing a shorter list is something that I think would be desirable for one level of list structure whereas `cdr-safe' seemed to make sense for nested levels. -- Dr Richard Stallman (https://stallman.org) Chief GNUisance of the GNU Project (https://gnu.org) Founder, Free Software Foundation (https://fsf.org) Internet Hall-of-Famer (https://internethalloffame.org)