From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Heime via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help Subject: Re: Advantage using mapc over dolist Date: Tue, 03 Dec 2024 19:35:20 +0000 Message-ID: References: <87zflevbwm.fsf@neko.mail-host-address-is-not-set> <87o71su8jz.fsf@neko.mail-host-address-is-not-set> <87v7w04ler.fsf@neko.mail-host-address-is-not-set> Reply-To: Heime Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3956"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier , "Alfred M. Szmidt" , help-gnu-emacs@gnu.org To: Tomas Hlavaty Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 03 20:36:45 2024 Return-path: Envelope-to: geh-help-gnu-emacs@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 1tIYhR-0000qz-5O for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 03 Dec 2024 20:36:45 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIYgZ-00065I-00; Tue, 03 Dec 2024 14:35:51 -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 1tIYgE-0005zv-V2 for help-gnu-emacs@gnu.org; Tue, 03 Dec 2024 14:35:35 -0500 Original-Received: from mail-4027.protonmail.ch ([185.70.40.27]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tIYgD-0001w8-0G for help-gnu-emacs@gnu.org; Tue, 03 Dec 2024 14:35:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1733254524; x=1733513724; bh=Yk5/q3t2tjBOx79oAT97qpSe+eqefokreZmpizOdCbo=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=Xx8rlLH8eBwKb37hLSOAEGIXSZx9c+Fx3Kt0JBhDOGSt0hRStS+d+Mby63DwtgaxA PrBfnUz3sdv+Uurm2EPWBqh+K82Pc62d3e1ry+jcTGdry6KAlJaUFkbBuD94/MXNH1 Tf5ECumUnZ4SayQzFUCLNbBYz2/B9iK8Yzvz1QqfzNBrmZeSCBHrEbIS9Pk4/YuoCu PheSkHWHSwCmW9ILLtBnHT4sZhQHmi5mU/z9sg9i9SKXRHIvvGeQotvRRm99JafkVO QmFIYYo0qfyfASoOCjpQu12M1S+fqb+Hz6WlxB38F2Io9JUL1DqGyI0jeeDeTjMoyY iJKqb7POlsE5g== In-Reply-To: <87v7w04ler.fsf@neko.mail-host-address-is-not-set> Feedback-ID: 57735886:user:proton X-Pm-Message-ID: 6a1077a92ed633ecfd5976e14f46a822169f592c Received-SPF: pass client-ip=185.70.40.27; envelope-from=heimeborgia@protonmail.com; helo=mail-4027.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:148556 Archived-At: Sent with Proton Mail secure email. On Wednesday, December 4th, 2024 at 7:27 AM, Tomas Hlavaty = wrote: > On Tue 03 Dec 2024 at 12:24, Stefan Monnier monnier@iro.umontreal.ca wrot= e: >=20 > > > > on the contrary, it is better to use specific tools and avoid more > > > > general tools when possible in order to lower cognitive load. > > > > Again, that's a personal preference. If you have to learn the more > > > > general tool anyway, then having to additionally learn the more spe= cific > > > > tool may increase rather than lower the cognitive load. > > > > Then why not use COND*? > >=20 > > AFAICT, the "cognitive load" of a complex pattern language is about the > > same for `pcase` as for `match*` since the two pattern languages are > > very similar. > >=20 > > And in the case of code that can use `case/ecase`, `cond*` doesn't seem > > to provide much benefit over just `cond` or `pcase`. Compare: >=20 >=20 > not only syntax but also semantics is important >=20 > not only things that are possible are important > but also things that are not possible >=20 > very limited stuff can happen using case/ecase >=20 > this is not the case with pcase so one has to keep in mind many more > possibilities >=20 > compare IF and WHEN. IF is more general and using your logic, one > should use IF and forget WHEN. however, the reduction of cognitive load > comes also from things that cannot happen, e.g. there is no "else" > branch to watch out for when using WHEN. Thus writing (if x 42) is > worse than writing (when x 42). It conveys the intention much better. > And is more robust. >=20 > > (pcase actm > > ('armg (do-this)) > > ('go (do-that)))) >=20 >=20 > (let ((x 'go)) > (pcase x > ('armg 1) > ('go 2))) > =3D> 2 >=20 > (let ((x 'go)) > (pcase x > (armg 1) > (go 2))) > =3D> 1 >=20 >=20 > here the PATTERN leads to many more possibilities >=20 > > (case actm > > (armg (do-this)) > > (go (do-that)))) >=20 >=20 > (let ((x 'go)) > (cl-case x > ('armg 1) > ('go 2))) > =3D> 2 >=20 > (let ((x 'go)) > (cl-case x > (armg 1) > (go 2))) > =3D> 2 >=20 >=20 > here the KEYLIST leads to much less possibilities >=20 > > (cond > > ((eq actm 'armg (do-this))) > > ((eq actm 'go (do-that)))) > >=20 > > vs > >=20 > > (cond* > > ((eq actm 'armg) (do-this)) > > ((eq actm 'go) (do-that))) > >=20 > > or > >=20 > > (cond* > > ((match* `armg actm) (do-this))) ((match*` go actm) (do-that)))) >=20 >=20 > obviously these examples are significantly worse than CASE >=20 > you meant: > (cond > ((eq actm 'armg) (do-this)) > ((eq actm 'go) (do-that))) >=20 > and cond is simpler and more specific than cond* >=20 > so again, use simpler, more specific tool for the job and the code will > be more readable and maintainable You want to do same job, finding a specific command that has the capability for doing nothing else than what you need is wasting your time. But there are many who like to delve on the technicalities about what they use, and are not much interested is just getting the job done. =20 > pushing for general omnipotent > use-me-i-can-do-everything-youll-ever-need macro is a bad idea Total nonsense. If a function can do what you need, use it.