unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: "Mattias Engdegård" <mattiase@acm.org>
Cc: Manuel Uberti <manuel.uberti@inventati.org>,
	emacs-devel <emacs-devel@gnu.org>
Subject: Re: Recent pcase changes
Date: Thu, 04 Mar 2021 09:39:41 -0500	[thread overview]
Message-ID: <jwv1rcvm1gn.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <586BC11A-0E1F-48ED-B69D-0ED2E809A0DE@acm.org> ("Mattias Engdegård"'s message of "Thu, 4 Mar 2021 12:30:58 +0100")

>> 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))
                          ^^^^^
                          `(,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




  parent reply	other threads:[~2021-03-04 14:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-04 10:06 Recent pcase changes Manuel Uberti
2021-03-04 11:30 ` Mattias Engdegård
2021-03-04 11:40   ` Omar Polo
2021-03-04 11:44   ` Manuel Uberti
2021-03-04 14:39   ` Stefan Monnier [this message]
2021-03-04 14:41     ` Manuel Uberti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv1rcvm1gn.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=manuel.uberti@inventati.org \
    --cc=mattiase@acm.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).