emacs-devel
[Top][All Lists]
Advanced

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

Re: Instead of pcase


From: Dmitry Gutov
Subject: Re: Instead of pcase
Date: Sun, 19 Nov 2023 15:49:52 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

On 18/11/2023 05:04, Richard Stallman wrote:
         > (`(,_ . ,(and (pred functionp) f)) (funcall f))
         > (`(,hookfun . (,start ,end ,collection . ,plist))

I read the Info documentation of pcase a few days ago and I can't
recall the rules for understanding those two pcase clauses.  What I
recall is that they are not to be interpreted as Lisp expressions.
They contain code that looks like Lisp but does not have the same
semantic rules as Lisp.

Yes: it's a domain-specific language.

To interpret those backquotes and commas, one can imagine that the they do the inverse of the usual.

If normally you have commas to insert the values from the environment (variables or expressions) into the backquoted form, then inside pcase they are used to do the opposite: to extract values from the expression at given positions, and bind them with given names in the corresponding clause's environment.

I think that's pretty clever, but also quite readable once you "grok" the above idea.



reply via email to

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