[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Code for cond*
|
From: |
Richard Stallman |
|
Subject: |
Re: Code for cond* |
|
Date: |
Tue, 30 Jan 2024 22:32:42 -0500 |
[[[ To any NSA and FBI agents reading my email: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
> Is this what you're referring to?
> ((get (car subpat) 'cond*-expander)
> ;; Treat result as a subpattern.
> (cond*-subpat (funcall (get (car subpat) 'cond*-expander) subpat)
> cdr-safe bindings backtrack-aliases data))
> do we have reasons to believe that it's flexible enough?
Nobody is actually using this now, so now is the best time
to make changes -- perhaps to make it somehow more flexible.
But I have no concrete idea of what flexibility you wish for.
Can you make a concrete suggestion? Then I might understand.
> Pcase currently doesn't support exactly this, but does support it within
> the backquote pattern, i.e. instead of
> [PAT1 PAT2 ...]
> you have to use
> `[,PAT1 ,PAT2 ...]
I think that's what people will actually want to use.
I meant here to imitate pcase, but I did not remember it in detail.
So I made both forms work in cond*, but maybe the latter is the only
one we really need.
> except that in Pcase, the value is passed as the last argument rather as
> first argument. I haven't seen a strong reason to prefer one over the
> other.
With the cond* syntax for simple constrained variables,
that ordering is natural. the variable to be bound
goes in the same spot as its value will be passed to the predicate.
(< x 15) as a pattern means, conceptually, bind x and evaluate (< x 15).
So the question is whether to use
(pred < x 15)
or just
(< x 15)
I prefer the latter because it is more concise.
The equivalent (and (pred...) car) is used often in pcase
so other forms ofit will be used often also.
--
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)
Re: Code for cond*, Richard Stallman, 2024/01/25
Re: Code for cond*, Richard Stallman, 2024/01/25
Re: Code for cond*, Alan Mackenzie, 2024/01/24
- Re: Code for cond*, Emanuel Berg, 2024/01/24
- Re: Code for cond*, Manuel Giraud, 2024/01/24
- Re: Code for cond* - cond*-match, cond*-subpat and backtrack-aliases, Alan Mackenzie, 2024/01/25
- Re: Code for cond* - cond*-match, cond*-subpat and backtrack-aliases, Richard Stallman, 2024/01/28
- Re: Code for cond* - cond*-match, cond*-subpat and backtrack-aliases, JD Smith, 2024/01/29
- Re: Code for cond* - cond*-match, cond*-subpat and backtrack-aliases, Richard Stallman, 2024/01/31