emacs-devel
[Top][All Lists]
Advanced

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

Re: cond* vs pcase


From: Arthur Miller
Subject: Re: cond* vs pcase
Date: Wed, 07 Feb 2024 19:36:56 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

"Alfred M. Szmidt" <ams@gnu.org> writes:

>    I am not sure if Alfred meant that in his first message, perhaps he did, 
> but
>    Drew seems to be more in line with that thinking. At least I understand 
> him so.
>
> I'm not alluding to any specific design principle, the core issue at
> hand is communicating with the person reading the code.

Yes, that is how I understand you; but I'll answer same as to Drew; I don't
agree that this is the best way of expressing the intention.

Both pcase and cl-case in this particular simple context I have posted, express
the intention equally well. It is rather that you are aware of the details of
cl-case and pcase and understand that the pcase is more powerful and can express
more powerful constructs. However just that fact that it is more powerful, does
not mandate use of "simpler" construct. As Adam illustrated, in this particular
scenario, cond, cl-case and pcase expressed equally well the intention. The
runtime cost is about the same too; so I don't think the implementation deatails
should guide the decision. That seems to me like some sort of premature
optimization, peep-hole optimization of intentions. I am not sure how to express
myself here :).

> The reason why we have ASSOC, ASSQ, ... are because they make it

I am not sure if the reason is the clarity. I think we have, with all right,
gone away from abbrevs and accronys such as "assq" or "memql" in function and
variable names to more self-documenting code. Those functions are historical
artefacts in my eyes.

> _clear_, _easy_ to understand code and to _use_.  A generic version is
> not as easy to understand, or use.  Which is also a reason why
> keywords are generally eskewed in Emacs Lisp.

Is this not clear and understandable:

(member elt list #'eql)
(memeber elt list :test 'eql)

Can we be more explicit in communication the intention which test funciton to
use, if communicating exactly that intention is really important.

Approoos nameing and historical artefacts, I read once an interview with Ken
Thompson; I don't remember on which site, so I don't have the link, but they
were asking him a bit about Unix design and a bit about C language amongst other
things. On the question if he regret anything abotu Unix design, he said, if he
regret he used "creat" instead of "create" as the name for the syscall.

Best regards
/arthur



reply via email to

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