From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: Instead of pcase Date: Sun, 19 Nov 2023 19:59:42 +0200 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> 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="9800"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 To: Barry Fishman , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 19 19:00:57 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 1r4m6J-0002MW-GA for ged-emacs-devel@m.gmane-mx.org; Sun, 19 Nov 2023 19:00:56 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r4m5J-0000Wd-6N; Sun, 19 Nov 2023 12:59:53 -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 1r4m5H-0000WV-74 for emacs-devel@gnu.org; Sun, 19 Nov 2023 12:59:51 -0500 Original-Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r4m5D-0007Ps-TF for emacs-devel@gnu.org; Sun, 19 Nov 2023 12:59:50 -0500 Original-Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 8F7745C00F0; Sun, 19 Nov 2023 12:59:46 -0500 (EST) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sun, 19 Nov 2023 12:59:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1700416786; x=1700503186; bh=MHk4myVP/ciP0+mW1ntC+jdHohWyllAJ6ul 8KCqhC+Q=; b=BkDM2mdKBm2hAOEADja6/GJq/BF3A+HnkWqpgmXJydY6K4aTTaR jyVwg1dKpzHo382WR6hh1Th+1CkKOVIr/tD8LwRHvm1Y1e3Q6YlyzP6dsO29DOBA HSk+28DaOLjzF7DUiOhLRtEHMLNnpVopQk95XrWOQ/8BhUhd9o3VL7rhIqueV/yE nB2EvAqA+Sgq8jGw/MO2rEKDXoYkIKUm701UPovEwXCwPYW1O3AcX8IThM8OAPzG wlRzTpbR797QDl42UeDra5D9kGAjQQm6DWRxcjJ6mgF0i6r6+bRJwKUojlAyiyOt xjCYpIVJbQiBfE1+ylksl5ltQtqd5p2jeiw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1700416786; x= 1700503186; bh=MHk4myVP/ciP0+mW1ntC+jdHohWyllAJ6ul8KCqhC+Q=; b=m VCyNvNwNoKTEORSLl6zCfiBQMBTjzGlm9CgwXIPJMtA6KtUugNuQc7e6cBUeYkH/ UAd8rHYae+yRGVt+0aVgTBn2EquZFaCZU+gp6BycX4834DTZHy7Qom7xBX7FRXeD dISwL7Cni0JeJwniKJGsv7qJJ6uJUvla718KFJbiNDJdwnK5x1wHnqeoJaZgmf6F UN5bn55+7TVerHliGxQXpwqvhLCwZCle/jABlVzTwu7VLPNP4qzZJOjimcGT6HwU o2AonSs71OO5fNsb3FMUSjpo75TC5rev10s1tfeiFcNQoi9F1t+6iqTPh8WhNtwZ 4lytYFB55juIOat1H0t3g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudeggedguddtkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefkffggfgfuvfhfhfgjtgfgsehtjeertddtfeejnecuhfhrohhmpeffmhhi thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth htvghrnhepgeehtdehudejieetuedttdejkeehjeetueekheffuddtjeeuvdefveeuveei uddunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepug hmihhtrhihsehguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 19 Nov 2023 12:59:45 -0500 (EST) Content-Language: en-US In-Reply-To: <7nmsv9zq6u.fsf@ecube.ecubist.org> Received-SPF: pass client-ip=66.111.4.29; envelope-from=dmitry@gutov.dev; helo=out5-smtp.messagingengine.com X-Spam_score_int: -75 X-Spam_score: -7.6 X-Spam_bar: ------- X-Spam_report: (-7.6 / 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, NICE_REPLY_A=-3.74, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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:313006 Archived-At: On 19/11/2023 18:02, Barry Fishman wrote: > On 2023-11-19 13:23:17 +01, Michael Heerdegen wrote: >> So, the advantage would be more of a psychological kind: you have normal >> Lisp function calls, but structurally you have the same thing, and you >> have to remember exactly the same set of details. The complexity comes >> from the task, not from the implementation. > > I submit that the opposite is true, the complexity is in its > implementation, not the task. > > In languages like Haskell this is expressed in a very simple way, so the > task is not in itself hard to understand. Haskell is notable for using the same (or similar) syntax for destructuring as it uses for constructing expressions. pcase actually follows that practice with backquotes and commas. And in both matching and destructuring are done in the same expression (the presence of the latter is determined by whether a pattern contains variable bindindgs). > If x is a list with its first element a string "foo" and the second an > integer, remove it from x and add the second element to total: > > (proto-case x > ((list* (string name) (integer count) (t rest)) > (string-equal name "foo") > (set! total (+ total count)) > (set! x rest))) > > This is just one of many other ways one could setup a matching > expression in elisp, the best is a balance between implementation > efficiency and readability. And this divorces matching from destructuring. I suggest you try rewriting one of the more complex pcase usages into this syntax and see what people think of the result.