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 13:43:30 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Yuri Khan <yuri.v.khan@gmail.com> writes:

> On Wed, 7 Feb 2024 at 01:58, Philip Kaludercic <philipk@posteo.net> wrote:
>
>> Please don't be dishonest; My question was why cl-case was more
>> appropriate than pcase, where both are macros that boil down to simpler
>> primitives.
>
> The design principle that Alfred alludes to is known as the [Rule of
> Least Power][0]. That advocates using the least powerful construct
> that still does the job. Like specialized mapcar instead of a
> general-purpose while loop, or an http client instead of coding
> directly against tcp sockets.
>
> [0]: https://en.wikipedia.org/wiki/Rule_of_least_power

I think it is a bad application of this principle in this context. Sitting an
deciding if there is a less-powerful condition form, or mapping functon for the
job sounds to me like a peep-hole optimization of Lisp, and as Monnier said
once, without benefit of the additional speed.

Before someone pulls out "eval"; that would be a completely different case, pun
intended.

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.

If we going to have guiding principles that help us construct our programs, in
my opinion PAIP book by P. Norvig has few good advices:

    * Be specific.
    * Use abstractions.
    * Be concise.
    * Use the provided tools.
    * Don't be obscure.
    * Be consistent.

He sas:

    "Sometimes, however, the maxims are in conflict, and experience will tell
    you which one to prefer."

Than comes the example with push vs setf, with reasoning about both, which he
finnishes with following advice:

    "Whichever choice you make on such issues, remember the sixth maxim: be
    consistent."

Which I think is the most relevant for this discussion.

https://norvig.github.io/paip-lisp/#/chapter3

(It is Free to read and put online by the author himself.)




reply via email to

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