[Top][All Lists]

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

RE: pcase-if-let?

From: Drew Adams
Subject: RE: pcase-if-let?
Date: Wed, 28 Mar 2018 21:14:01 -0700 (PDT)

> #+begin_src emacs-lisp
> (defmacro pcase-if (clauses then-form &rest else-forms)
>   "Eval THEN-FORM or the ELSE-FORMS depending on CLAUSES.
> CLAUSES is a list of the form \((PATTERN VALUE-FORM) ...)

We usually try to describe the args in order (first CLAUSES
then THEN-FORM, then ELSE-FORMS.  So, for example:

  Depending on CLAUSES, evaluate THEN-FORM or ELSE-FORMS.

> Successively try to match every `pcase' PATTERN against
> its VALUE-FORM.  When all match, eval THEN-FORM, else the

About the name "pcase-if"...

If that's what this does then why does the name instead
tell us "case" (suggesting a selection, e.g. one of
several cases)?

The name might be better off telling us that this is
an `if-all-match' (or even just `if-all'): If ALL of
the clauses match then do THEN-FORM, else do ELSE-FORMS.

It's the "all" and the "match" that are important,
together with the fact that this is an if-then-else.
It's not really about "case" at all (except in the
sense that there are two cases: THEN and ELSE).  In
Lisp, a `case' construct, like `cond', has always
been about choosing among multiple cases, not just
a single test with two case outcomes.

And why the asymmetry between THEN being singular
and ELSE being plural?  Emacs-Lisp `if' has such an
asymmetry (for a couple of reasons, which aren't
particularly relevant here), but why should this
`pcase-if' construct be asymmetric? Why not make it
symmetric, like `cond' (and `case'), since it's
already a complex, multipurpose critter?

I'm guessing that all of this `pcase-*' stuff has
taken its names from `pcase'.  But that just took
its name, AFAIK, from `case' and "pattern".

This naming is no longer relevant, is it?  There's
no set of "cases" involved.  Is there really a big
benefit in naming everything that uses a "pcase-style"
pattern "pcase-<SOMETHING>"?  Presumably you want to
use similar names to convey the fact that they all
do pattern-matching.

But if what these things have in common is the
_pattern_ (and they all share the same kinds of
pattern-matching, for the most part), then why
emphasize "case" in the name?  And why make people
guess that the "p" stands for "pattern" and is what
these are all about?

Not that I really care much - don't get me wrong.
I just don't find such names very helpful.  They
don't really say what they're about (not very

reply via email to

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