emacs-devel
[Top][All Lists]
Advanced

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

Re: Instead of pcase


From: João Távora
Subject: Re: Instead of pcase
Date: Tue, 9 Jan 2024 10:43:00 +0000

On Tue, Jan 9, 2024 at 5:33 AM Stefan Kangas <stefankangas@gmail.com> wrote:

> > You take a backtick-starting construct with as many scary periods
> > things as you can find and then, say
> >
> > `(,foo . (,bar . ,baz))
> >
> > And then ask yourself: "what kind of list does this build if I just
> > let-bind foo, bar and baz to 42?". And then you answer yourself
> > "Why, it's the improper list (42 42 . 42) made up of just two cons
> > cells and 3 fixnums!".  So _that's_ the kind of list that can be
> > destructured with the pcase expression.
> >
> > This solves the reading problem.  Now the writing problem. To author
> > new pcase patterns one uses more or less the same process.  One again
> > leans on one's existing knowledge of how the list structure would be
> > expressed with backtick-and-quote.  So once you know the list
> > structure in your mind you write it as a backtick-and-quote expression,
> > just as if you were going to craft that list (though you aren't of
> > course).  Then once you're happy with your expression, you may take it
> > and you put it in one of the BINDINGS left-hand part of a 'let'.
> > Then you rename that 'let' to 'pcase-let' and away you go!
>
> Could you reformat this as a documentation patch?

TL;DR: Maybe I will do that "if noone beats me to it" (TM).

All the ideas I had to share are already there and free to use.
If you find these ideas useful or their exposition elegant,
I'm flattered :-)  but there's still the work of finding the correct spot
in the pcase documentation where they would fit better and
identifying what other parts of that doc they now supersede, so
that a cohesive whole can be achieved.

This is usually the most difficult part of adding to existing
documentation (very similar to maintaining code, actually).
Then there are more minor stylistic and formatting issues, but
these are still some effort.

I don't have the resources to do this work right now, and
properly coordinate with other people updating other parts of
that documentation.

João



reply via email to

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