emacs-devel
[Top][All Lists]
Advanced

[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. 


reply via email to

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