From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.devel Subject: Re: cond* vs pcase Date: Tue, 06 Feb 2024 17:50:01 +0000 Message-ID: <87ttml8oty.fsf@posteo.net> References: <87il32iwmm.fsf@posteo.net> <87o7cttu4l.fsf@posteo.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5848"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "Alfred M. Szmidt" , 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 18:50:34 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 1rXPab-0001Fj-0f for ged-emacs-devel@m.gmane-mx.org; Tue, 06 Feb 2024 18:50:33 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXPZo-00034c-RL; Tue, 06 Feb 2024 12:49:44 -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 1rXPZn-00034T-5x for emacs-devel@gnu.org; Tue, 06 Feb 2024 12:49:43 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXPZl-00036p-4l for emacs-devel@gnu.org; Tue, 06 Feb 2024 12:49:42 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 49E54240027 for ; Tue, 6 Feb 2024 18:49:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1707241777; bh=2RYngNTYuJhz26KrRSqGG9xwdebMV6i2Wo3yaKOJa7Q=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: Autocrypt:OpenPGP:From; b=V4MpsfzqU3q/7Pbl7WHtlJDrDa5Qjd1sE4myUK2elxeoJjZh129x1hyxENWqu2+aY cJ9uZ01grCfs0KhrNXMxvMCkc8JKbwk6DtFf5tIlywkPWXsNYrZl7P99L2IkXgNvhP P72uD2zsYR+38/QcA+8Ku6ro8tFFIpSL9zmZjLak58a84gKGzGg+6IZoLAXdgXn+yn 72fGSt4Xd6nfrYEnBd7YCS+yiucQLzdiE1UAPcndKp8jyAzgGlV0bBIVVG+BW9jeW3 ZW5hFSjS/s0J0R78FT6W/Ts8nJjiE+sHETKlGcw2p23JNhEly+MKrRRO9lrSMgKbWh ufkhWEMpyialQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4TTrNc17hnz6txn; Tue, 6 Feb 2024 18:49:35 +0100 (CET) In-Reply-To: <87o7cttu4l.fsf@posteo.net> (Philip Kaludercic's message of "Tue, 06 Feb 2024 16:50:02 +0000") Autocrypt: addr=thievol@posteo.net; prefer-encrypt=mutual; keydata=xsDNBF8ylcIBDADG+hy+zR6L4/vbdDDZuSaMmSrU3A5QZJpeBCvxTr7MpzzruZbhLPW1K3R6N2MA edi8Y+C8o27FVRIjpdbaKMGu9je7JV/TbUQYo3SOwCK1vM4LUn4V6ZLzSYkuiEt4eyMoiDdyvN0p kcK6P9x9DCetcEVszXzQg+yzCVrQ2hXWDXWT4M18EC3wtO7RHPouMqGiwBFhBAYErCqFWFxQHkfb tG/4yGyJ58rglb65O3qijjMWvYwcWZun9/7qm8Z4/4mHopmo2zgU+OrptnLSZfkZGz3Y7Uf452xQ GVq0Fv75NPvQru7y+DYVhuVXXyAmGxt+vf4rIiixMBbhKEPjcxEPAa2LTzex2IsTZR+QVG9uDnqC WcgaOEQ58fzXNvNhtwwF/Rgio2XWAJVdmFWS59/k9W58CIUSNKBMZh2XeGdEmtHvDtCxW3z6FJha 36RzOM3fMNNiAGdFZJA84gcdloJR+sHCDTTPT3784fjr+V8An7sI581NGFzkRQqPvEQCZbUAEQEA Ac0SdGhpZXZvbEBwb3N0ZW8ubmV0wsEOBBMBCgA4AhsDBQsJCAcCBhUKCQgLAgQWAgMBAh4BAheA FiEEI9twfRN7r3nig/xwDsVtFB0W75MFAmL3HCoACgkQDsVtFB0W75OVEAv/f6XxmtIFz08fUb8h Bp/zJP6IC4/rhhh+0GMRIRzLN8DK0jV8JCzYdFHiRJOy2lNIOpmrrCmjRRxferc2G42+ePFIsslx hU46VSz1Z83NwIG3mpdYNV5WUTUdgzxExHTNTFCd7NKv0nlHKQaA OpenPGP: url=https://posteo.de/keys/thievol@posteo.net.asc; preference=encrypt Received-SPF: pass client-ip=185.67.36.65; envelope-from=thievol@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=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:315941 Archived-At: Philip Kaludercic writes: > "Alfred M. Szmidt" writes: > >> "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/.... > > Simply because pattern matching is a more powerful generalisation, > capable of expressing case-distinction; in the end it compiles down to > almost the same code anyway. > >> 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... > > I don't understand your point here. If one expects the cases to be > evaluated, then quoting makes sense if you want to match a symbol. It > is not true, but common enough that the byte compiler emits a warning. > >> > 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. > > I am sorry, but I don't follow your point here either. Is the general > claim, that one should only use whatever exactly and at most satisfies > the needs at hand? Also interning strings just for the purpose of comparing them with eq or eql is questionable... -- Thierry