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: Tue, 12 Dec 2023 23:58:20 -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> <87zfza2aq2.fsf@web.de> <7nmsv9zq6u.fsf@ecube.ecubist.org> <7nv89x5tsi.fsf@ecube.ecubist.org> <87o7focuf5.fsf@web.de> <875y1r10jr.fsf@web.de> <87v895iyzy.fsf@web.de> 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="17509"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: michael_heerdegen@web.de Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Dec 13 05:58:55 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 1rDHKh-0004Oe-K3 for ged-emacs-devel@m.gmane-mx.org; Wed, 13 Dec 2023 05:58:55 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rDHKB-0000JJ-KG; Tue, 12 Dec 2023 23:58:23 -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 1rDHKA-0000Hw-8z for emacs-devel@gnu.org; Tue, 12 Dec 2023 23:58:22 -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 1rDHKA-00072L-0c; Tue, 12 Dec 2023 23:58:22 -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=mVtvS4reE7GQUPqss5OXFJcrhOFJFpgi2Onl20JYwGo=; b=Ojktaf0FEchN gn3AOz2KmlYqtuLAg2CvWA/GbHwGImSx/lpYyv4U6pnaS5ciGSbvFTcyT89SZSuzY0pXlSc7JUvwL S4NGw0YR0v2SwKBL6evlForoG8FwC9DbJIYydTK2t4EUfbtkTfww3pW4edhUKoJ8flfmMSXRjGQco amdl4ifFn/BcEWHvPTrJwoV5sLXuLpk4K/HgBwNatGytSukGOX/EVtadajsRjfUkKO+jD2cXPpY6V pXSsAiHzujSJI/y4oH0/Rpt8UttsqvDqFgrxyO0O82WQ/6+BE8LA86URoZSenWls9eA+yFzQvCo3D k75uxwNgUs5xnpQbb/8cSQ==; Original-Received: from rms by fencepost.gnu.org with local (Exim 4.90_1) (envelope-from ) id 1rDHK8-0004pZ-Ok; Tue, 12 Dec 2023 23:58:20 -0500 In-Reply-To: (message from Richard Stallman on Mon, 11 Dec 2023 22:43:44 -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:313740 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 was compelled to copy pcase's `_' meaning "match anything" because I could not see a way to do this with anything less arbitrary. If anyone sees a cleaner way to do this, please tell me. Here is the current definition of patterns for use in cond*. **Possible types of patterns for :match and the match-... functions** CONSTANT: nil, t, a keyword, a quoted constant, fixed parts of a backquote This matches any value equal to CONSTANT. _ _ means to match any value and not store it anywhere. VARIABLE: a symbol A symbol means to match any value and set VARIABLE to it. A quoted cons cell The car and the cdr are subpattenrs. The cons cell pattern matches any cons cell whose car and cdr match those two subpatterns. How nil as a cdr matches is controlled by the match-nil flag. When the nil-match-all flag is false, nil as a cdr matches only nil itself. When the nil-match-all flag is true, nil as a cdr matches any object and ignores that object. The nil-match-all flag is false by default. The `cdr' pattern maks it false within its its subpattern, and the `cdr-safe' pattern makes it true forwithin its its subpattern. (cdr-safe QUOTED-CONS-CELL) This pattern is equivalent to QUOTED-CONS-CELL by itself except that it makes the nil-match-all flag true within it. (cdr-safe `(a b)) matches (a b), (a b c), (a b . d), etc. (cdr QUOTED-CONS-CELL) This pattern is equivalent to QUOTED-CONS-CELL by itself except that it makes the nil-match-all flag false within it. (cdr `(a b)) matches only (a b). 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))) Alternatives: (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)