[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Code for cond*
From: |
JD Smith |
Subject: |
Re: Code for cond* |
Date: |
Wed, 24 Jan 2024 10:29:24 -0500 |
> On Jan 24, 2024, at 4:45 AM, Stefan Kangas <stefankangas@gmail.com> wrote:
>
> JD Smith <jdtsmith@gmail.com> writes:
>
>> But oddly enough, this thread discussing its potential replacement has
>> given me the key insight — “imagine running list interpolation
>> backwards”. … A short introductory paragraph in
>> the elisp pcase documentation which explains this approach to its
>> novel syntax would have gone a long way for me.
>
> Patches welcome.
To explain this correctly, I’d need to understand where the mental model breaks
down. For example, I was surprised that this forward/reverse symmetry was not
maintained:
(let ((list-var '(foo moo loo))
(other 'boo))
`(,@list-var . ,other)). ; -> (foo moo loo . boo)
(pcase '(foo moo loo . boo)
(`(,@list-var . ,other)
(format "Got %S: %S" list-var other))). ; -> nil, expected “Got (foo moo
loo): boo"
I also noticed that "Backquote-Style Patterns: Backquote Patterns.” is quite
deep in the pcase doc structure, coming just after “Extending ‘pcase’:
Extending pcase. Define new kinds of patterns.”. Yet most pcase examples I
come across in the wild use backquote patterns. I don’t know if that’s an
intentional arrangement, or was put in place before people had experience with
pcase and voted with their key-taps for backquote style.
- Re: Code for cond*, (continued)
- Re: Code for cond*, Alan Mackenzie, 2024/01/24
- Re: Code for cond*, Emanuel Berg, 2024/01/24
- Re: Code for cond*, Po Lu, 2024/01/25
- Re: Code for cond*, Emanuel Berg, 2024/01/25
- Re: Code for cond*, Po Lu, 2024/01/25
- Re: Code for cond*, Emanuel Berg, 2024/01/25
- Re: Code for cond*, Richard Stallman, 2024/01/19
- Re: Code for cond*, Stefan Monnier, 2024/01/23
- Re: Code for cond*, JD Smith, 2024/01/23
- Re: Code for cond*, Stefan Kangas, 2024/01/24
- Re: Code for cond*,
JD Smith <=
- Re: Code for cond*, Stefan Monnier, 2024/01/24
- Re: Code for cond*, Stefan Monnier, 2024/01/24
- Re: Code for cond*, JD Smith, 2024/01/24
- Re: Code for cond*, Stefan Monnier, 2024/01/24
- RE: [External] : Re: Code for cond*, Drew Adams, 2024/01/24
- RE: [External] : Re: Code for cond*, Drew Adams, 2024/01/24
- Re: Code for cond*, Madhu, 2024/01/25
- Re: Code for cond*, Stefan Monnier, 2024/01/25
- Re: Code for cond*, JD Smith, 2024/01/25
- Re: Code for cond*, JD Smith, 2024/01/25