bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#68509: 30.0.50; pcase-dolist matches backquote pattern incorrectly


From: Stefan Monnier
Subject: bug#68509: 30.0.50; pcase-dolist matches backquote pattern incorrectly
Date: Mon, 19 Feb 2024 21:41:43 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

Ihor Radchenko [2024-02-19 18:14:24] wrote:

> Stefan Monnier <monnier@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






reply via email to

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