[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Installing cond* in core
From: |
Alan Mackenzie |
Subject: |
Re: Installing cond* in core |
Date: |
Fri, 2 Feb 2024 15:24:01 +0000 |
Hello, Stefan.
On Fri, Feb 02, 2024 at 08:17:25 -0500, Stefan Monnier wrote:
> > > I think the question is rather: why should we have two equivalent and
> > > almost identical matching syntaxes and implementations?
> > That is the easiest way to make cond* function.
> Only if you consider "easiest" at each small incremental step.
> The overall cost of what you've done is already much higher :-)
> > I do not understand the pcase code for implementing pattern matching,
> You don't need to understand it.
I've needed to understand it, and I also found it difficult to
understand.
I've also found difficult the macro expansions which pcase produces.
cond* might be easier here, though it's too soon to tell.
> > A priori, I suspect it won't fit. cond*-subpat, which does this job
> > in cond*, passes data up and down the recursion. I can't tell whether
> > pcase does something comparable. Also, cond*-subpat does not generate
> > the overall structure of a clause -- its caller, cond*-match, does
> > that.
> Throw away cond*-subpat. Just rewrite
> (cond*
> ((match* PAT FORM) THEN)
> . ELSE)
> into something like
> (pcase FORM
> (PAT THEN)
> (_ (cond* . ELSE)))
> And presumably for
> (cond*
> ((match* PAT FORM))
> . REST)
> you'd rewrite it to
> (pcase-let ((PATH FORM))
> (cond* . REST))
> No need to look inside or understand `pcase.el` at all!
But that would rule out the possibility of simplifying pcase by
rewriting it in terms of cond*. ;-)
> Stefan
--
Alan Mackenzie (Nuremberg, Germany).
Re: Installing cond* in core, Richard Stallman, 2024/02/04