emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [External] : Re: cond* vs pcase


From: Drew Adams
Subject: RE: [External] : Re: cond* vs pcase
Date: Tue, 6 Feb 2024 19:12:17 +0000

> > Are you suggesting that COND/CASE/... and other "trivial" matching
> > constructs should be replaced with PCASE/COND*?
> 
> No, just that using pcase in these cases isn't wrong.
> 
> Drew Adams <drew.adams@oracle.com> writes:
> 
> >> Simply because [1] pattern matching is a more
> >> powerful generalisation, capable of expressing
> >> case-distinction; [2] in the end it compiles
> >> down to almost the same code anyway.
> >
> > Wow.  Really _not_ a good reason (IMHO).
> > Neither of those reasons [1,2] is good.
> >
> > With that reasoning you'll use `pcase'
> > _always and everywhere_ - never `if',
> > `cond', `let', `or', `and',...
> 
> Please don't be dishonest;

Huh?  Why would you think/claim I'm being
dishonest?  Care to elaborate?

> My question was why cl-case was more
> appropriate than pcase, where both are macros that boil down to simpler
> primitives.  I don't see an inherent advantage to using the more
> specific abstraction over the more generic one.  I like pcase, and
> prefer using it in my code, but if you've got some code that is already
> using a lot of cl-lib and no pcase, then there is no point in
> transiting cl-case forms into pcase.

The inherent advantage is what I & others
have pointed out: clearer _intention
expression_ for human readers.

It says, in effect, "This just tests the
value for simple equality (using this or
that equality predicate)."  It speaks
quietly, humbly, clearly.

`pcase' advertises instead: "Here come the
Big Guns, which can wrestle _anything_ to
the ground!  Stand in awe and wonder."

No one is saying someone can't use `pcase'
for whatever they like.  It's about style.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]