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: Instead of pcase Date: Sat, 02 Dec 2023 22:27:14 -0500 Message-ID: References: <87fs169mjj.fsf@posteo.net> <093f11a1-57c2-5e56-d39b-26fef1c67cbb@gutov.dev> <25942.25061.217864.329049@retriever.mtv.corp.google.com> <87zfzdcz6z.fsf@posteo.net> <763f067b-4ca9-1eba-9f3c-424c38589e9c@gutov.dev> 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="27478"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Dec 03 04:28:07 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 1r9d9K-0006tS-8H for ged-emacs-devel@m.gmane-mx.org; Sun, 03 Dec 2023 04:28:06 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9d8X-0005fg-9D; Sat, 02 Dec 2023 22:27:17 -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 1r9d8V-0005fY-Kh for emacs-devel@gnu.org; Sat, 02 Dec 2023 22:27:15 -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 1r9d8V-0008Eq-AS for emacs-devel@gnu.org; Sat, 02 Dec 2023 22:27:15 -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=0BIm8MG+sk9zmyZGFnvvhav/WqI3NkS2anHsXxWlZpA=; b=nFlM+CvHOQYw 8bcN9Zx0RBFqC5CNo27gsX0mY1IP3nXVVa0P5aT0y81Neyv75G8gr7DfCjRCCIxnaL6qSueI5pHXE uM6eJ5M4X+azhzON3zYOXHvmBJ9pvXPZqyn160dLg7BufDb1eYOgIn+0J6AsuLbE4KpItSOsTDP/l veNQcx6f+3XICXE/PSEn6idR1GwXDt/w18uJDb72n+BSaNFo3qsPKHGp2I3dVe4ZwxPeh9L4kQbvN tvD5SXsFQjG8VnOyFbOSh7kLAczQ64dtD516c0/7Z4uO+l7K+fYboEVWpxUC5Ux3+xu3jV088f1WA uhHzLNZPlZnWLKfgAFecqw==; Original-Received: from rms by fencepost.gnu.org with local (Exim 4.90_1) (envelope-from ) id 1r9d8U-0006Sn-JA; Sat, 02 Dec 2023 22:27:14 -0500 In-Reply-To: (message from Richard Stallman on Fri, 01 Dec 2023 22:20:40 -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:313480 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. ]]] I foudn it necessary to add a little of the complexity of pcase, but in a more elegant form. Here's what I have now, for patterns to match. **Possible types of patterns for :match and the match-... functions** `CONSTANT A constant means to match any value equal to CONSTANT. VARIABLE, a symbol A symbol means to match any value and set VARIABLE to it. nil nil means to match any value and not store it anywhere. Constrained variable, (TESTFN VARIABLE OTHER-ARGS...) This matches any value VALUE provided (TESTFN VALUE OTHER-ARGS...) evaluates to true. If so, it sets VARIABLE to VALUE. (symbolp sym) Match any symbol, store it in `sym'. (> num-foos 1) Match any thing greater than 1, store it in `num-foos'. When matching to bind variables, this pattern unconditionally binds VARIABLE whether it matches or not. `quote', `constrain' and `or' cannot be used as TESTFN. Constrained variable constructs can be nested. For example, (< (numberp num-foos) 1) Match any number > 1, store it in mum-foos. General constrained variable, (constrain VAR EXPRESSION) This general constrained variable pattern binds VAR to the value being matched against, only for evaluating EXPRESSION. If the result is non-nil, the match succeeds and sets VAR to the value. For instance, (constrain x (and (> x 0) (< x 100))) Multi-alternative, (or SUBPATTERNS...) This tries to match each of the SUBPATTERNS in order until one matches. If the pattern is being used to bind variables, it binds all the variables specified in any of SUBPATTERNS -- 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)