From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Alfred M. Szmidt" Newsgroups: gmane.emacs.devel Subject: Re: cond* vs pcase Date: Tue, 06 Feb 2024 11:17:05 -0500 Message-ID: References: <87il32iwmm.fsf@posteo.net> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27687"; mail-complaints-to="usenet@ciao.gmane.io" Cc: arthur.miller@live.com, emacs-devel@gnu.org To: Philip Kaludercic Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Feb 06 17:17:58 2024 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 1rXO8z-0006ss-Ri for ged-emacs-devel@m.gmane-mx.org; Tue, 06 Feb 2024 17:17:58 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXO8D-000866-E8; Tue, 06 Feb 2024 11:17:09 -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 1rXO8B-00085x-A2 for emacs-devel@gnu.org; Tue, 06 Feb 2024 11:17:07 -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 1rXO89-0007hN-Bs; Tue, 06 Feb 2024 11:17:05 -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=QAt7w11VvMpsnyqPTYPCTUsdXsuPNA/fkpPhkzc66pE=; b=j8undI9JwBEg mr5x5KTgMG2OHJBeuyoHLnGOcM0V8rVpgKYxoyd9lR02uiyxwkRlt0pn+q3ANhVUPFx2IUpaeyHvC /AWJNttk/FKrHmQ2vI8aN1Bqmef9iw+0AyuRhlcaB3iHlcQd6rG8isjmxuptVSn/XRqoYgEctincj VbwGdWA8ccEqN1SB8ORf11lRGhS611AGjj+apdxL3rLUuPT8wFPVdX8Og3nxO/QWU1brmUODNjZtr ES/TpXpiw6WKr9cpypckR33WDLaPGkrTUZ1WoTaF5INEBDlPrfaGjZ2sOebz2+cFM5vQqXZb+xYcf cGMUKVEm6cytZy0C1RFRDw==; Original-Received: from ams by fencepost.gnu.org with local (Exim 4.90_1) (envelope-from ) id 1rXO89-0003Ll-3B; Tue, 06 Feb 2024 11:17:05 -0500 In-Reply-To: <87il32iwmm.fsf@posteo.net> (message from Philip Kaludercic on Mon, 05 Feb 2024 18:39:13 +0000) 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:315930 Archived-At: "Alfred M. Szmidt" writes: > I use pcase often; but I use it just as a better cond. For example I find this > handy: > > (defvar foo nil) <-- foo is some symbol > > (pcase foo > ('bar (do-some-bar-stuff)) > ('baz (do-some-baz-fluff))) > > cl-case seems more appropriate here (wish cl-case was just case ...) Why more appropriate? Because your not doing pattern matching, you're comparing against a set of strings/symbols/numbers/.... I always think of pcase as Elisp's case. In addition, pcase avoids the danger of naively writing (cl-case foo ('bar (do-some-bar-stuff)) ('baz (do-some-baz-fluff))) and then getting surprised when foo evaluates to `quote'. Suprises will happy, you will get suprises with pcase and cond* too -- I find it suprising that to match over symbols requires pattern matching. One might also question why you (well, no you specifically) are comparing against (quote bar) etc? That is a suprise in it self... > or this: > > (setq foo "some-string") > > (pcase foo > ("foo" (do-foo-case)) > ("bar" (do-bar-case))) > > Same here, with (intern foo) ... Being able to do equal instead of eql is also something that speaks in favour of pcase... It speaks more in favor of having CASE where you can change the comparison operator or a CASE-STRING or similar, not something much more generic pcase (or even cond*!) -- i.e. why use pcase/cond* when you're not using any of the features that are the main point of those two macros.