From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Adam Porter Newsgroups: gmane.emacs.devel Subject: Re: Instead of pcase Date: Wed, 20 Dec 2023 04:52:17 -0600 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28692"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: emacs-devel@gnu.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Dec 20 11:53:28 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 1rFuCb-00072j-DQ for ged-emacs-devel@m.gmane-mx.org; Wed, 20 Dec 2023 11:53:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rFuBf-0007bv-EV; Wed, 20 Dec 2023 05:52:27 -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 1rFuBd-0007b6-3A for emacs-devel@gnu.org; Wed, 20 Dec 2023 05:52:25 -0500 Original-Received: from dog.elm.relay.mailchannels.net ([23.83.212.48]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rFuBb-0008WF-D9; Wed, 20 Dec 2023 05:52:24 -0500 X-Sender-Id: dreamhost|x-authsender|adam@alphapapa.net Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 7D61D7A019F; Wed, 20 Dec 2023 10:52:19 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a283.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 191FE7A26C7; Wed, 20 Dec 2023 10:52:19 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1703069539; a=rsa-sha256; cv=none; b=RKmWkoy30Bdfb2Xkr1BgBIk1OKmEjX1b+fwb7X9MNoPlyRh4oZpxzO5IT460MIBPNloQwp xTlrSKOAesPLXa0oKa+3V4I9TKdLWg1gY8DNLTXwTcGp1jIaR3qhDBOndnJIf3HFwwKD3a L12zgeJ0skQ5aa6g+zJvhjfKgfbca7HYUVhcIsuV6oLMTvptSrQLGXO0Z2rqDjisedpvD1 fAFkuQqo97+gDJBvf1EwtdDoY4MkSZJ3DY2pyItK6cWdcHszY4dbpxlVQ78GiUe3wi+FNU /VIrBruutD32eW0nmhZ+1j3fZK9Fit7m647eYTSHDv2cDV3tKTPE1O0j9dwlSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1703069539; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=07q/CsNE9jB9vsiQFBUu3lW4FEJ1GUhDj0Y+9vfZg3U=; b=M2gfLc9gcxdqqmTl2H30YVS/qj/I0EeuzFf3SlM6UXkaI/eiFAr+Rp91BH3K4CfVyEbnC8 Cg/9Gw0i6JVfnQL4MgI1QCoEAunkmfbXasAaaslXm+ve2Xs5CSvhbBg++3i1Ht1vg+mjAx zqhvhtsH5lDHDvKZ+K1HYiPDfhAgWfYrPrHaNN1iphGpVxDzi1pfevy8n78ePMSvJG/Wlo YFGs8MbN7d9yTskwlKPYzyVGr0JUyyqTppV79ufQgCPtHhl9dPslPzX7sVIcqMghgV4rWY IkUl6l4YpOtWwYvCiwAlbnLpWWNM0j6/Zaryz5fMaDXCKalnzoI0Ev3/QlxYRQ== ARC-Authentication-Results: i=1; rspamd-856c7f878f-76gnw; auth=pass smtp.auth=dreamhost smtp.mailfrom=adam@alphapapa.net X-Sender-Id: dreamhost|x-authsender|adam@alphapapa.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|adam@alphapapa.net X-MailChannels-Auth-Id: dreamhost X-Company-Arithmetic: 1cd6221e66912c72_1703069539338_886099706 X-MC-Loop-Signature: 1703069539338:356119598 X-MC-Ingress-Time: 1703069539337 Original-Received: from pdx1-sub0-mail-a283.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.109.35.101 (trex/6.9.2); Wed, 20 Dec 2023 10:52:19 +0000 Original-Received: from [10.66.0.34] (unknown [91.193.232.98]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: adam@alphapapa.net) by pdx1-sub0-mail-a283.dreamhost.com (Postfix) with ESMTPSA id 4Sw9PG42jsz1R; Wed, 20 Dec 2023 02:52:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alphapapa.net; s=dreamhost; t=1703069538; bh=07q/CsNE9jB9vsiQFBUu3lW4FEJ1GUhDj0Y+9vfZg3U=; h=Date:Subject:To:Cc:From:Content-Type:Content-Transfer-Encoding; b=rWopWokZnssvYkZMlJUzhlr23AKA1eJbJOAldrg0QdS7LllGhvzgoGqDXhPzqYk0R 4YHh929pnt91tpaIiDKYa8ItRfdXVsUwP69exGDD03zWTlIkawz09t4aATbFpdXr2B 6+WQxVgBojJQkpK+4gEYLKET//2pb8EIhSjT3gTI6DnZiJgyn3pxiNcZlolsYwy8SV kg8aP+G3cmexkKulu5ZHLhP9FN/ZNdO0+Yx4SL5IXf4IkbJKsvWQARV9xf1DarWzGn r5nL20JUI4vHhbxXlwOheZ0ij0jqloH+IN4KtgErkLDPfijJrZwkxshRYq75vgVbPU CC4XCy+sDPuqQ== Content-Language: en-US In-Reply-To: Received-SPF: neutral client-ip=23.83.212.48; envelope-from=adam@alphapapa.net; helo=dog.elm.relay.mailchannels.net X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NEUTRAL=0.779, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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:314019 Archived-At: On 12/19/23 21:28, Richard Stallman wrote: > I find these examples hard to understand because of the complexity > caused by the functions called `bar'. I did not add those functions to the example myself; I merely elaborated on them to illustrate the problems I was pointing out. > I could not fully make sense of the first one: I don't understand > what you intend it to do, or what you think it might do, or why it > might do that. Yes, that is part of the point I am making: that the way COND* binds variables and passes them to predicate forms is confusing. > Is it possible that the explanation of a constrained variable patterm > is not clear? > > 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'. > > Only the first argument to a TESTFN is a kind of subpattern. The > OTHER-ARGS are handled are not patterns to match; they are > expressions to evaluate. Their values are passed to TESTFN as in an > ordinary function call. > The first parameter of `bar' will be data that this subpattern may > match or not. The remaining parameters of `bar' will be the results > of evaluating OTHER-ARGS... Yes, this is one of the problems I was trying to illustrate. What if the TESTFN needs VALUE as its second or later argument rather than as the first? Or what if TESTFN needs to receive multiple arguments bound from a matched pattern? What if TESTFN needs 3 arguments, and the middle one is not from the matched pattern? Or what if the middle one /is/ from the matched pattern? And what if there are naming conflicts among VARIABLE and OTHER-ARGS? What if some of those symbols are already bound outside the COND* or in another clause of it that falls through? PCASE handles these situations in a better way by matching and binding separately and explicitly, providing the GUARD form to evaluate arbitrary expressions, which may or may not include variables bound in the pattern.