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: Garreau\, Alexandre
Subject: Re: Replace trivial pcase occurrences in the Emacs sources
Date: Thu, 01 Nov 2018 20:35:41 +0100
User-agent: Gnus (5.13), GNU Emacs 25.1.1 (i686-pc-linux-gnu, GTK+ Version 3.22.11) of 2017-09-15, modified by Debian

Le 01/11/2018 à 20h07, Eli Zaretskii a écrit :
>> From: "Garreau\, Alexandre" <address@hidden>
>> Cc: address@hidden,  address@hidden
>> Date: Thu, 01 Nov 2018 06:21:49 +0100
>> 
>> >> >   @dfn{Destructuring} of an object is an operation that extracts
>> >> >   multiple values stored in the object, e.g., the 2nd and the 3rd
>> >> >   element of a list or a vector.  @dfn{Destructuring binding} is
>> >> >   similar to a local binding (@pxref{Local Variables}), but it gives
>> >> >   values to multiple elements of a variable by extracting those values
>> >> >   from an object of compatible structure.
>> >> 
>> >> “(car list)” is extracting a value stored in an object, yet it’s not
>> >> destructuring (though a list is a structure).  Nor even is “(cons (car
>> >> list) (caddr list))” or “(setq a (nth 1 list) b (nth 2 list))”.
>> >
>> > You forget the "multiple" part in the description.
>> 
>> Then you forgot “(cons (car list) (caddr list))” which I proposed later.
>
> The values need to be extracted in one go, so the above doesn't
> qualify.

Let’s say this was in a language were arguments evaluation order is not
specified, and it is wrapped as macro/function set-two-vars-from-car-and-caddr,
how wouldn’t that match your definition?

After all this later form can be considered as atomic, or pcase as not
atomic (it will necessarily get one value before the other), to me
that’s no what’s relevant to the destructuring concept: pcase requires a
pattern to specify matched data structure (same for
cl-destructuring-bind).  That’s what makes “destructuring”.

Another example: the pcase and pcase-* forms are destructuring, but the
lambda pcase-* forms (full of car, cdr and other structure extraction
functions call) are not destructuring, because they don’t refer to
matched data structure, don’t specify it, and even ignore anything not
being related to what it needs to fetch.

>> Wasn’t my definition attempt okay? it even defined three quite used and
>> intuitive terms.
>
> It didn't look like a more clear description to me, no.

Do you have some more precise suggestion on why is not clear and how to
clearly phrase the concept of “specifying a matched data structure”, or
should I just give up and accept the rest of world is fine with a more
loose, large, less specific, and according to me, wrong, definition of
“destructuring”?



reply via email to

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