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: Tue, 30 Jan 2024 22:32:42 -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="10485"; 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 Wed Jan 31 04:33:36 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 1rV1M0-0002X3-FV for ged-emacs-devel@m.gmane-mx.org; Wed, 31 Jan 2024 04:33:36 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rV1LH-0007RP-H5; Tue, 30 Jan 2024 22:32:51 -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 1rV1LD-0007R1-JD for emacs-devel@gnu.org; Tue, 30 Jan 2024 22:32:47 -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 1rV1LC-00034c-NL; Tue, 30 Jan 2024 22:32:46 -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=i36BrKyQwpacsh6m8T0gBJUNIfS8MDnsxadKzCPlqKs=; b=ETTI+JVEbowy KBxHJ+NF0f+dDvX6fkb0UCuv+1c1A6DJ1vXxhO90WbIMFiNZKytSebbkkDI91vmQgThYMrLx4DmFe /6rMDSfTJQm2jZqdADAsTx8l8MvZHMq6aRMZ60dMn5HwZwz+aB14zJ+CUP8u4E/evKL2EBTNYymP6 MpryLZT9mB/vKveY2EOvRb8V6Xo4zAB6WL4bVq931OHbqiBJYFYfB+lSvHE2jn6xA2283qYA2Onzl w0KREvaom/013rW6EaXDpwIxaswL8qEpnk1xNxp2aNOwBpdo753mUQB2iq/WlEN0IzkbMaELwIyRh vnmw9u1f+irMRKv52iMsPg==; Original-Received: from rms by fencepost.gnu.org with local (Exim 4.90_1) (envelope-from ) id 1rV1L8-0007SL-PF; Tue, 30 Jan 2024 22:32:43 -0500 In-Reply-To: (emacs-devel@gnu.org) 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:315652 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. ]]] > Is this what you're referring to? > ((get (car subpat) 'cond*-expander) > ;; Treat result as a subpattern. > (cond*-subpat (funcall (get (car subpat) 'cond*-expander) subpat) > cdr-safe bindings backtrack-aliases data)) > do we have reasons to believe that it's flexible enough? Nobody is actually using this now, so now is the best time to make changes -- perhaps to make it somehow more flexible. But I have no concrete idea of what flexibility you wish for. Can you make a concrete suggestion? Then I might understand. > Pcase currently doesn't support exactly this, but does support it within > the backquote pattern, i.e. instead of > [PAT1 PAT2 ...] > you have to use > `[,PAT1 ,PAT2 ...] I think that's what people will actually want to use. I meant here to imitate pcase, but I did not remember it in detail. So I made both forms work in cond*, but maybe the latter is the only one we really need. > except that in Pcase, the value is passed as the last argument rather as > first argument. I haven't seen a strong reason to prefer one over the > other. With the cond* syntax for simple constrained variables, that ordering is natural. the variable to be bound goes in the same spot as its value will be passed to the predicate. (< x 15) as a pattern means, conceptually, bind x and evaluate (< x 15). So the question is whether to use (pred < x 15) or just (< x 15) I prefer the latter because it is more concise. The equivalent (and (pred...) car) is used often in pcase so other forms ofit will be used often also. -- 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)