[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: combining cond and let, to replace pcase.
From: |
Michael Heerdegen |
Subject: |
Re: combining cond and let, to replace pcase. |
Date: |
Tue, 21 Nov 2023 16:53:37 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Richard Stallman <rms@gnu.org> writes:
> Here's an example to show what I have come up with along these lines:
>
> (cond* (:bind (x foobar) y z (foo 5) a) ;; variables to bind, as in let
> ;; I'm also thinking of using nil instead of :bind.
>
> ;; t as condition means run this clause unconditionally
> ;; then continue with next clause.
> (t do-this-unconditionally-and-dont-stop...)
>
> ;; Tests with a new function `match' which I'm going to work on next.
> ((match x 'foo) ...)
>
> ;; t in the last clause means the same as in previous clauses,
> ;; but you can think of it as being the same as in `cond'.
> (t do-this-as-last-resort)
> )
>
> Rhe idea is that conf* does part of pcase's added functionality, and
> `match' will do the rest. But it is not necessary to cram _all_ the
> additional matching functionality (to compare to pcase) into a single
> new function. We could have more than one new function, eacn for its
> own kind of pattern matching.
I've also sometimes missed a cond-let. I think the above example shows
something slightly different: binding is done in one branch, but the
bindings are visible in all (following?) branches (instead of only the
branch BODY). So that's, at least in this example, more or less an
amalgamated let + cond. The interesting part, the matching, is not
shown, so I only have a vague imagination of the whole picture.
Have you continued working on this approach in the meantime?
Michael.
- Re: combining cond and let, to replace pcase., (continued)
- Re: combining cond and let, to replace pcase., Michael Heerdegen, 2023/11/21
- Re: combining cond and let, to replace pcase., Dmitry Gutov, 2023/11/19
- Re: combining cond and let, to replace pcase., Eli Zaretskii, 2023/11/19
- Re: combining cond and let, to replace pcase., Dmitry Gutov, 2023/11/19
- Re: combining cond and let, to replace pcase., Gerd Möllmann, 2023/11/19
- Re: combining cond and let, to replace pcase., Tomas Hlavaty, 2023/11/19
- Re: combining cond and let, to replace pcase., Stefan Monnier, 2023/11/24
- Re: combining cond and let, to replace pcase., Alan Mackenzie, 2023/11/19
- Re: combining cond and let, to replace pcase., Michael Heerdegen, 2023/11/21
- Re: combining cond and let, to replace pcase., Axel Forsman, 2023/11/19
- Re: combining cond and let, to replace pcase.,
Michael Heerdegen <=
- Re: combining cond and let, to replace pcase., Richard Stallman, 2023/11/22
- Re: combining cond and let, to replace pcase., Tomas Hlavaty, 2023/11/23
- Re: combining cond and let, to replace pcase., Richard Stallman, 2023/11/25
- Re: combining cond and let, to replace pcase., Tomas Hlavaty, 2023/11/27
- Re: combining cond and let, to replace pcase., Yuri Khan, 2023/11/27
- Re: combining cond and let, to replace pcase., Tomas Hlavaty, 2023/11/28
- Re: combining cond and let, to replace pcase., Manuel Giraud, 2023/11/23
- Re: combining cond and let, to replace pcase., Richard Stallman, 2023/11/25
- Re: combining cond and let, to replace pcase., Daniel Semyonov, 2023/11/23
- Re: combining cond and let, to replace pcase., Daniel Semyonov, 2023/11/23