emacs-devel
[Top][All Lists]
Advanced

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

Re: Replace trivial pcase occurrences in the Emacs sources


From: Alan Mackenzie
Subject: Re: Replace trivial pcase occurrences in the Emacs sources
Date: Thu, 1 Nov 2018 10:36:33 +0000
User-agent: Mutt/1.10.1 (2018-07-13)

Hello, Achim.

On Thu, Nov 01, 2018 at 09:36:54 +0100, Achim Gratz wrote:
> Am 31.10.2018 um 17:20 schrieb Eli Zaretskii:
> > I think we can do better in this part:

> >      Evaluate BODY with bindings made by matching PATTERN to each
> >      element of LIST in turn.  PATTERN is a pcase pattern

> > I think using "matching" here is detrimental to understanding what's
> > going on, which is a destructuring binding that uses pcase patterns.
> > (The "matching" here is between the structures of PATTERN and elements
> > of LIST, but the usual meaning of "matching" in Emacs is different,
> > especially when "patterns" are mentioned nearby.  So we should not use
> > "matching" here, at least not without significant qualifiers, like
> > "structure matching" or somesuch.)

> > And this:

> >      Should the matching fail for any LIST element, the results are
> >      undefined.

> > should be reworded to explain that elements of LIST should have a
> > structure compatible with PATTERN, so that the destructuring works.

> How about this:

> PATTERN describes the expected structure of LIST and is used to 
> establish bindings to corresponding elements of LIST during evaluation 
> of BODY.  Undefined behaviour results if the structure of LIST is 
> different from that described by PATTERN.

That doesn't say clearly that BODY is executed once for each LIST
element.

I would also go for "... the expected structure of each LIST element ..."
and "... bindings of the corresponding parts of the element during ....".
And one or two other changes.  That would give something like this:

    (pcase-dolist (PATTERN LIST) BODY...)

    Loop over a list, evaluating BODY for each element of LIST in turn.

    PATTERN describes the expected structure of each LIST element and is
    used to establish bindings to the corresponding parts of the element
    during the evaluation of BODY.  Undefined behavior results if the
    structure of any LIST element is different from PATTERN.

    For a description of PATTERNs, see `pcase'.  See also `dolist'.

What do you think?

> -- 
> Achim.

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

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