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: Sat, 16 Dec 2023 00:57:43 -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="24505"; 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 Sat Dec 16 07:58:48 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 1rEOdM-0006CC-ET for ged-emacs-devel@m.gmane-mx.org; Sat, 16 Dec 2023 07:58:48 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rEOcV-0002oP-BZ; Sat, 16 Dec 2023 01:57:55 -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 1rEOcT-0002oH-HZ for emacs-devel@gnu.org; Sat, 16 Dec 2023 01:57:53 -0500 Original-Received: from rusty.tulip.relay.mailchannels.net ([23.83.218.252]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rEOcQ-0001T6-0Q; Sat, 16 Dec 2023 01:57:53 -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 16ACBC1D81; Sat, 16 Dec 2023 06:57:46 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a300.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id A2E63C1BD3; Sat, 16 Dec 2023 06:57:45 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1702709865; a=rsa-sha256; cv=none; b=M9Hc+0k18rf2KyAeR8v4bpMG3G7u2hJs+a1aiL40Mqo4Iij/VpdSjxu6yxUelIYO0zOfPf vzYLU7366F11SSt6Mr9fNbcEpbHd2D7NdB9BeuUlWo8parR+ur9zOcXse1DNnP694JDraF 48WxD5owwq3plQqZ/xNYDcgRiyJgQaQ2970pvfDDMIY5jf3LgYbQyDeQ0q8tog8Sk6UUeX ysWUTdA67ESuwtDAFld9wwoNJhktmJy3hcWrBCsiBAEfl7Z+0AbGc0lR14rIf4EuN/c1w/ SOaJq9RJMeP6ql2g76VAEqbmKEgJaavShNLZnZyn8Re3uroJUFUQmdhKD66kkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1702709865; 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=zVrnkTxf0X9dSklsxJMst4IujDk2hlG1fjenLq666Hk=; b=tm7+paoQCO+5dp21HmBVCfE1U9JYPiY7Kge5HFKnoy/tLknM6AUbzUNpCjIcBC+7HGKi5y HwHgEMwNh3bRZ3Wp7aciZUvE9XrR0hiD38BBdwSi7fIcVZX2RsECaIKBrUTzfuQDUJK5mN FCxDowtF8tNPjdy/WudskVfzihZQk4hUGZU3gWktU5cZP7NRJiAMACBrQ44QEuAwDlveTu dRkLy+XvJMs5x1nrtos/pbdtuI5meCJ/H9T7sILwAsQF+EiOEoYxQg6zPs6XssAZw+8Qjd +JwTMSP3qraZCy5dPiSNKPYNqjLnBF8c1gLmJAny6Xs/wLOAuyIRnGVjOTgY8g== ARC-Authentication-Results: i=1; rspamd-d8b88b4b9-9jbzs; 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-Left-Hook: 26daaf573c18228e_1702709865910_1011198860 X-MC-Loop-Signature: 1702709865910:4085959980 X-MC-Ingress-Time: 1702709865910 Original-Received: from pdx1-sub0-mail-a300.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.104.199.175 (trex/6.9.2); Sat, 16 Dec 2023 06:57:45 +0000 Original-Received: from [10.43.0.222] (unknown [193.56.116.15]) (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-a300.dreamhost.com (Postfix) with ESMTPSA id 4SscNT0tYqz1W; Fri, 15 Dec 2023 22:57:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alphapapa.net; s=dreamhost; t=1702709865; bh=zVrnkTxf0X9dSklsxJMst4IujDk2hlG1fjenLq666Hk=; h=Date:Subject:To:Cc:From:Content-Type:Content-Transfer-Encoding; b=CtnO+00cCpsI31x7TLxrFwrJBdQF5qvOR6obgNGMDKiM/ybxbZvzjAcax2v1vkMzn mCt1Wh+PFHwn/HIHlxrXiF2E+G3eDlS7qZ1P8cGwE+E5tIu8cYoAwFs9lBDNjWZpCO uKsKSIOkhqy5wDPmyp6b5sOWk70Tt/8iAhTRVVLu3RWe3ccAwK7EzjwmrTqBOnaceg ETDWEz5BgExhwZGaFn4pnl1/ckWqg2+Ks6tn+hzpDoqRTsAs+JOWXcr8E/ZVo9ZHx7 2PaiFv1fYZeyoEDSyZL9xJ2/DzPhhUPtpPfr+h+1p0rWqY9vrLAziFNozziqS5mh12 HKdbTf2sFEyvw== Content-Language: en-US In-Reply-To: Received-SPF: neutral client-ip=23.83.218.252; envelope-from=adam@alphapapa.net; helo=rusty.tulip.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:313868 Archived-At: Hello Richard, On 12/15/23 22:23, Richard Stallman wrote: > > As well, what if the user needed to pass an already-bound argument in > > addition to the one being bound there? With pcase, the binding would be > > explicit, and the accompanying `guard' expression would have a clear > > place in lexical scope, so there would be no doubt about where the > > arguments were bound. > > I am having trouble grasping the abstract description. Would you like > to show an example of the putative problem that you are concerned > about? I might understand it then. Here are some examples I put together that demonstrate, IMHO, that pcase's binding forms are more explicit and less confusing. ;; In the match, will "bar" be called with "CONST" or "FOO" as the ;; first argument? (cl-labels ((bar (one two) t)) (let ((foo 'FOO) (const 'CONST) (body '(CONST FOO))) (cond* (:match ((or `() `(,(bar foo const))) body))))) ;; In the match, will "bar" be called with "CONST" or "FOO" as the ;; first argument? (cl-labels ((bar (one two) t)) (let ((foo 'FOO) (const 'CONST) (body '(FOO CONST))) (cond* (:match ((or `() `(,(bar const foo))) body))))) ;; In the match, will "bar" be called with "FOO" or "B" as the second ;; argument? (cl-labels ((bar (one two) t)) (let ((foo 'FOO) (body '(A B))) (cond* (:match ((or `() `(,(bar const foo))) body))))) ;; pcase's bindings are more explicit and less confusing: (cl-labels ((bar (one two) t)) (let ((foo 'FOO) (const 'CONST) (body '(A B))) (pcase body ((or `() (and `(,const ,foo) ; Explicitly binds within scope of clause. (guard (bar const foo)))) ; Binding of "foo" clearly shadows that of the LET form. (format "CONST:%S FOO:%S" const foo)) (_ "No match")))) ;; "CONST:A FOO:B"