help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Advantage using mapc over dolist


From: Stefan Monnier
Subject: Re: Advantage using mapc over dolist
Date: Tue, 03 Dec 2024 12:24:48 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

>    > 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 specific
>    tool may increase rather than lower the cognitive load.
> Then why not use COND*?  

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.

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:

    (pcase actm
     ('armg (do-this))
     ('go (do-that))))

vs

    (case actm
     (armg (do-this))
     (go (do-that))))

vs

    (cond
     ((eq actm 'armg (do-this)))
     ((eq actm 'go (do-that))))

vs

    (cond*
     ((eq actm 'armg) (do-this))
     ((eq actm 'go) (do-that)))

or

    (cond*
     ((match* `armg actm) (do-this)))
     ((match* `go actm) (do-that))))


- Stefan




reply via email to

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