From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Instead of pcase Date: Sat, 25 Nov 2023 10:53:34 +0200 Message-ID: <83cyvydxip.fsf@gnu.org> References: <87o7ftlaim.fsf@neko.mail-host-address-is-not-set> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34070"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Nov 25 09:54:32 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 1r6oQp-0008do-VG for ged-emacs-devel@m.gmane-mx.org; Sat, 25 Nov 2023 09:54:32 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r6oPy-0005yz-K7; Sat, 25 Nov 2023 03:53:38 -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 1r6oPx-0005ym-EU for emacs-devel@gnu.org; Sat, 25 Nov 2023 03:53:37 -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 1r6oPx-0001kR-6H; Sat, 25 Nov 2023 03:53:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=bqG2nJ9P4vYDm/Lzgsl3BJdR/wyEN+5/u3GuRovtaKc=; b=UOWZGEVOXaik lAMTcIA+XbUtjL1X2hYXk6nFtXSo1g+tGGyR0t7I9p0I0HZOE/KBFcJMO2iH0WjF4UfZV8l4knL3e ByuEAXNXc6QmCDhfdh2tqaFfBZfNqSvFWfYu73RC0is2SiPrK6Gj1l0224ChK5cppuQO8lrDzs5w2 l6dd2ECTlDndkCgw8v5UjBx8EAKPsObbuDaknmbJCum6ZQFHBh8shQSfyBLbBOMQfEnRbrdq9tKk+ 53Wqkq6utdp/eAjQwcwqseiOK3rM+OgDSlfmZB+v7L0LUtUYcnNbyjp/s7ULlwsv6uRVghEbMpXwv xfdRs8OG0O+zB6Edj188sw==; In-Reply-To: (emacs-devel@gnu.org) 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:313201 Archived-At: > Date: Fri, 24 Nov 2023 23:34:24 -0500 > From: Stefan Monnier via "Emacs development discussions." > > > (let ((exp (if t '(foo . "str") '(bar . 7)))) > > (cl-case (car exp) > > (foo > > (when-let ((d (cdr exp))) > > (concat "str" val))) > > (bar > > (when-let ((d (cdr exp))) > > (1+ val))))) > > AKA > > (let ((exp (if t '(foo . "str") '(bar . 7)))) > (case (car exp) > ('foo > (when-let ((d (cdr exp))) > (concat "str" val))) > ('bar > (when-let ((d (cdr exp))) > (1+ val))))) > > Funnily enough this quoting of the values against which we want to match > is so natural for coders not familiar with `cl-case` that we went > through some efforts to try and detect their mis-use. > > So at least for some coders, in the above case, the `pcase` syntax is the > more natural one :-) And 'cond' is more natural yet (in these simple cases). Basically, all that pcase saves us there is the call to 'eq'.