emacs-devel
[Top][All Lists]
Advanced

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

Re: Instead of pcase


From: Jim Porter
Subject: Re: Instead of pcase
Date: Mon, 20 Nov 2023 21:14:48 -0800

On 11/20/2023 6:42 PM, Richard Stallman wrote:
I uderstand that when you say it, but when I saw the line

          > (`(,hookfun . (,start ,end ,collection . ,plist))

I was not sure which part of the line that rule applies to.

In particular, what is the reason for the period and inner
parenthsses?  Why doesn't the code say this?

          > (`(,hookfun ,start ,end ,collection . ,plist)

Would that be equiva;ent?

Yes, These are equivalent (unless I'm severely mistaken):

----------------------------------------

(pcase '(func 0 10 coll plist1 plist2)
  (`(,hookfun . (,start ,end ,collection . ,plist))
   (message "hookfun = %s start = %s end = %s collection = %s plist = %s"
            hookfun start end collection plist)))

=> "hookfun = func start = 0 end = 10 collection = coll plist = (plist1 plist2)"


(pcase '(func 0 10 coll plist1 plist2)
  (`(,hookfun ,start ,end ,collection . ,plist)
   (message "hookfun = %s start = %s end = %s collection = %s plist = %s"
            hookfun start end collection plist)))

=> "hookfun = func start = 0 end = 10 collection = coll plist = (plist1 plist2)"

----------------------------------------

I could not assume the inner parenthsses were unnecessary.  Maybe
there was a conventiob by which they change the meaning.
I did not know.

I think this might be a case where the 'pcase' code was written in a more-cryptic-than-necessary manner, which adds extra confusion. This could be a good example to include in some documentation though: it can show how one's intuition about "ordinary" backquoted forms can apply directly to reading 'pcase'.



reply via email to

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