[Top][All Lists]

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

Re: Replace trivial pcase occurrences in the Emacs sources

From: Eli Zaretskii
Subject: Re: Replace trivial pcase occurrences in the Emacs sources
Date: Sun, 04 Nov 2018 16:16:19 +0200

> From: Michael Heerdegen <address@hidden>
> Cc: address@hidden,  address@hidden
> Date: Sat, 03 Nov 2018 23:22:02 +0100
> >                                     The node I pointed to describes
> > "backquote-style patterns", and explains that these "ease structural
> > matching".  The same patterns are useful for destructuring binding,
> > precisely because destructuring binding needs a structural match.
> > That is all that I'm trying to convey.  Making that point will help
> > the reader to understand what subset of pcase patterns will be most
> > useful for destructuring.
> So, I should read it as "the set of patterns that are of the form
> `SOMETHING"?  I had read it as the set of what we call "QPATs".  So we
> have probably talked about different things.

I refer to the patterns described in that section.  They are all
`SOMETHING, but not just any SOMETHING.  Does that answer your
question?  (Please don't talk about QPATs, that term no longer exists
in the manual, so using it is just making this discussion more
confusing than it already is.)

> I find the wording used in (info "(elisp) Backquote Patterns")
> confusing, especially the first sentence "This subsection describes
> “backquote-style patterns”, a set of builtin patterns that eases
> structural matching." which seems to introduce a whole set of builtin
> patterns though it talks only about one macro, `.
> You only refer to that in your change, using the same wording, so what
> you changed is consistent with what we have, although I don't like it
> that much.

The current description of pcase uses took a lot of time and effort to
get to the current shape, so I'm going to trust those who labored on
it that they found the best balance between clarity and accuracy.

In any case, that's a separate issue, let's please not mix them.  I
didn't change anything in that section, only referred to it.

> > Destructuring binding requires destructuring, that's all.
> "Destructuring binding" - pcase has nothing like that.

The section in question is not about pcase, it's about pcase-let,
pcase-let*, and pcase-dolist.

>                                                     We have a
> pattern type for binding, SYMBOL, and diverse for performing
> destructuring, ``' being the main and most general one.  You can combine
> these, but both are different things.

The macros described in the section we are talking about provide a
kind of binding.  I needed to describe how to use the combination of
the above, so I called that "destructuring binding", both to follow
terminology accepted in other languages and to provide a concise
description of this combination that doesn't require too many words.
Since you seem to agree that there is destructuring and there is
binding, I don't understand the nature of your objections to the term
"destructuring binding", as defined in this section.  Are you saying
that this description:

  [...] similar to a local binding (@pxref{Local Variables}), but
  gives values to multiple elements of a variable by extracting
  those values from an object of compatible structure.

is incorrect, or that pcase patterns don't allow them, or that
pcase-let etc. is not about using such bindings in the BODY?

> We talk about this paragraph:
> | +The pcase patterns that are useful for destructuring bindings are
> | +generally those described in @ref{Backquote Patterns}, since they
> | +express a specification of the structure of objects that will match.
> I would already be happy if you would leave out the word "bindings".
> Establishing bindings is not the only use of `.

The text doesn't say that the only use of ` is for establishing
bindings.  It says that destructuring bindings can be done by using
backquote-style patterns.  That's not the same, as you surely realize.
If A can be done by using B, it doesn't imply that B's only use is to
do A.  The text you quote says the former and never says anything to
imply the latter.  So I'm really surprised that you interpret it that

> > > | The pcase patterns that are useful for destructuring bindings are
> > > | generally those described in @ref{Backquote Patterns}
> > > 
> > > makes it sounds if ` is the only method to get destructuring bindings
> > > with pcase.
> >
> > No, it says those are _useful_ for destructuring bindings, that's all.
> > I'm sure you realize that saying A doesn't say that there's nothing
> > but A.
> Sorry, I'm not an native English speaker.  But "are generally those"
> sounds quite, well, generalizing to me ;-)

Would you be happier if the text said "typically" instead of
"generally"?  Because that's what it means.

> > Stefan's original text talked about extracting values (or subfields),
> > so it was clear to me that Stefan, too, alluded to destructuring.
> It talked about "extracting data".

It talked about extracting subfields of objects.  Isn't that

> It's also a difference between "... is typically used for" (which I
> would find ok) and "... does this and that" and it's not accurate.

Could you please tell what concrete changes in the doc strings of
pcase-let etc. would make you happier?  I feel that we are trapped in
abstract discussions with no clear way out, and I think I'm at least
slightly confused what is it that you don't like about the current
docs.  Concrete proposals for changes might go a long way towards
dispersing the fog.


reply via email to

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