all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Michael Heerdegen <michael_heerdegen@web.de>,
	Davis Herring <herring@lanl.gov>
Cc: Emacs Development <emacs-devel@gnu.org>
Subject: RE: pcase-if-let?
Date: Wed, 28 Mar 2018 21:14:01 -0700 (PDT)	[thread overview]
Message-ID: <60dc117a-7ee2-42d2-acbc-49dae9ec6ae1@default> (raw)
In-Reply-To: <87605filw6.fsf@web.de>

> #+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
> ELSE-FORMS."

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
discoverable).



  reply	other threads:[~2018-03-29  4:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-28 23:20 pcase-if-let? Michael Heerdegen
2018-03-28 23:54 ` pcase-if-let? Davis Herring
2018-03-29  0:21   ` pcase-if-let? Michael Heerdegen
2018-03-29  3:46     ` pcase-if-let? Michael Heerdegen
2018-03-29  4:14       ` Drew Adams [this message]
2018-03-29  4:39         ` pcase-if-let? Michael Heerdegen
2018-03-29  4:49           ` pcase-if-let? Drew Adams
2018-03-29  4:53           ` pcase-if-let? Stefan Monnier
2018-03-29  5:24             ` pcase-if-let? Michael Heerdegen
2018-03-29 11:59               ` pcase-if-let? Stefan Monnier
2018-03-30  1:52                 ` pcase-if-let? Michael Heerdegen
2018-03-30  4:07                   ` pcase-if-let? Drew Adams
2018-03-30  5:09                     ` pcase-if-let? Michael Heerdegen
2018-03-30 15:07                       ` pcase-if-let? Drew Adams
2018-03-30 23:22                         ` pcase-if-let? Michael Heerdegen
2018-04-17 20:26           ` pcase-if-let? Nathan Moreau
2018-04-17 21:04             ` pcase-if-let? Michael Heerdegen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=60dc117a-7ee2-42d2-acbc-49dae9ec6ae1@default \
    --to=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=herring@lanl.gov \
    --cc=michael_heerdegen@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.