GNU bug report logs -
#68509
30.0.50; pcase-dolist matches backquote pattern incorrectly
Previous Next
Full log
View this message in rfc822 format
Ihor Radchenko [2024-02-19 18:14:24] wrote:
> Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>
>>> * lisp/emacs-lisp/pcase.el (pcase-dolist): Use `pcase' rather than
>>> `pcase-let*' to match the list elements. Update the docstring,
>>
>> That changes its behavior. It *will* break code.
>> This is basically not the same macro any more. Instead of being a macro
>> that iterates over all the elements of the list, it becomes a macro
>> which iterates only over the matching elements.
>
> Currently, the docstring states:
>
> PATTERN should be a `pcase' pattern describing the structure of
> LIST elements, and LIST is a list of objects that match PATTERN,
> i.e. have a structure that is compatible with PATTERN.
The doc for `pcase-let` is a bit more precise:
Each EXP should match (i.e. be of compatible structure) to its
respective PATTERN; a mismatch may signal an error or may go
undetected, binding variables to arbitrary values, such as nil.
> In my patch, I proposed to skip such elements.
> An alternative could be throwing an error.
As I said, what you propose is a *different* construct.
Maybe we should add some extra option/keyword to `pcase-dolist` to
indicate what to do with elements that don't match (such as signaling
an error, a warning, silently skipping it, ...).
Similar issues affect `pcase-let`, of course.
Stefan
This bug report was last modified 1 year and 112 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.