[Top][All Lists]

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

Re: Recent pcase changes

From: Stefan Monnier
Subject: Re: Recent pcase changes
Date: Thu, 04 Mar 2021 09:39:41 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>> By looking at clojure-mode code I see it sets `lisp-indent-function' to
>> `clojure-indent-function', which makes use of `pcase'. More specifically, 
>> this
>> is what it does at line 1497 of clojure-mode.el:
>> (pcase method
>>  ((or (pred integerp) `(,method))

No good deed goes unpunished, eh?

> Now all variables in an `or`-pattern are always bound, to nil if nothing 
> else. Try:
>    ((or (pred integerp) `(m))

>     (let ((method (if (integerp method) method m)))

With the new semantics you could also use

    (pcase method
      ((or (pred integerp) `(,m))
       (let ((method (or m method)))

And to get something to work reliably with both the old and the new
semantics, you can go with:

    (pcase method
      ((or (and (pred integerp) method) `(,method))

-- Stefan

reply via email to

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