emacs-devel
[Top][All Lists]
Advanced

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

Re: pcase bindings in patterns with complicated logic


From: Ihor Radchenko
Subject: Re: pcase bindings in patterns with complicated logic
Date: Sat, 20 Jan 2024 12:48:39 +0000

Richard Stallman <rms@gnu.org> writes:

>   > My question was whether cond* can be used to implement an equivalent
>   > match as in my example above.
>
> The `or' pattern should do that job.
> In what way is it not sufficient?
>
>                                   AFAIU, cond* cannot match against multiple
>   > values at once.
>
> With the natural meaning, yes it can.  Perhaps we are miscommunicating.
> Could you explain what "match against multiple values at once" means to you?

I think we are indeed miscommunicating.
Let me provide another, more clear, example.

(pcase '((foo . 1) (bar . 2) (baz . 3))
  ((and `((foo . 1) . ,_)
        (app (mapcar #'cdr) `(,_ ,_ ,c)))
   (format "Match: %S" c)))

The above matches `((foo . 1) . ,_) against '((foo . 1) (bar . 2) (baz . 3))
and then matches `(,_ ,_ ,c) against a different value - '(1 2 3)

AFAIU, this is not possible with cond*.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



reply via email to

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