[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Replace trivial pcase occurrences in the Emacs sources
From: |
Clément Pit-Claudel |
Subject: |
Re: Replace trivial pcase occurrences in the Emacs sources |
Date: |
Tue, 30 Oct 2018 15:56:33 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 |
On 30/10/2018 14.14, Alan Mackenzie wrote:
> Hello, Clément.
Hey Alan :)
> On Tue, Oct 30, 2018 at 11:05:55 -0400, Clément Pit-Claudel wrote:
>> On 30/10/2018 10.16, Andy Moreton wrote:
>>> How are users meant to write reliable code using such constructs ?
>
>> Ensure that the pattern actually matches :)
>
> You mean, unless you can be 100% sure that the pattern will match, you
> mustn't use pcase-... constructs. That sounds equivalent to saying you
> shouldn't use these constructs at all.
That's an odd conclusion.
>> IOW, only use these constructs when it's an invariant of your program
>> that the pattern will match the data. For cases in which the pattern
>> might not match, use pcase instead of pcase-dolist.
>
> pcase is not a looping construct. pcase-dolist is. They're not
> replacements for eachother.
I should have written "use `pcase' with `dolist` instead of `pcase-dolist'".
Concretely, replace this:
(pcase-dolist (pat list) …)
with this:
(dolist (xyz list) (pcase xyz (pat …) (_ (handle-error-here))))
- Re: Replace trivial pcase occurrences in the Emacs sources, (continued)
- Re: Replace trivial pcase occurrences in the Emacs sources, Stefan Monnier, 2018/10/30
- Re: Replace trivial pcase occurrences in the Emacs sources, Alan Mackenzie, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Stefan Monnier, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Eli Zaretskii, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Alan Mackenzie, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Eli Zaretskii, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Alan Mackenzie, 2018/10/30
- Re: Replace trivial pcase occurrences in the Emacs sources, Andy Moreton, 2018/10/30
- Re: Replace trivial pcase occurrences in the Emacs sources, Clément Pit-Claudel, 2018/10/30
- Re: Replace trivial pcase occurrences in the Emacs sources, Alan Mackenzie, 2018/10/30
- Re: Replace trivial pcase occurrences in the Emacs sources,
Clément Pit-Claudel <=
- Re: Replace trivial pcase occurrences in the Emacs sources, Andy Moreton, 2018/10/30
- Re: Replace trivial pcase occurrences in the Emacs sources, Stefan Monnier, 2018/10/30
- Re: Replace trivial pcase occurrences in the Emacs sources, Clément Pit-Claudel, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Michael Heerdegen, 2018/10/30
- Re: Replace trivial pcase occurrences in the Emacs sources, Stefan Monnier, 2018/10/30
- Re: Replace trivial pcase occurrences in the Emacs sources, Michael Heerdegen, 2018/10/30
- Re: Replace trivial pcase occurrences in the Emacs sources, Stefan Monnier, 2018/10/30
- Re: Replace trivial pcase occurrences in the Emacs sources, Alan Mackenzie, 2018/10/30
- Re: Replace trivial pcase occurrences in the Emacs sources, Stefan Monnier, 2018/10/30
- Re: Replace trivial pcase occurrences in the Emacs sources, Alan Mackenzie, 2018/10/30