unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: Kaushal Modi <kaushal.modi@gmail.com>
Cc: Help Gnu Emacs mailing list <help-gnu-emacs@gnu.org>
Subject: Re: Using let-bound var inside pcase conditions
Date: Mon, 17 Apr 2017 22:33:39 +0200	[thread overview]
Message-ID: <87tw5mdba4.fsf@drachen> (raw)
In-Reply-To: <CAFyQvY2mmXaaC8kh6r6o5xZrtXSum8_oZ1G6Sfuaqy1WfuO+Ww@mail.gmail.com> (Kaushal Modi's message of "Mon, 17 Apr 2017 18:07:42 +0000")

Kaushal Modi <kaushal.modi@gmail.com> writes:

>     (message "(bad)  Value is %s." (pcase var
>                                      (`nil "nil")
>                                      (`,one "one")
>                                      (`,two "two")
>                                      (_ "none of the expected")))))

I also try this from time to time just to remember that it's wrong: the
first appearance of a symbol in a pcase pattern is never transformed
into an `eq'uality test.  Sometimes that's surprising (especially in
backquote patterns), but that's how it's defined.

BTW, `nil is equivalent to 'nil, and `,symbol is equivalent to just
symbol as a pattern.

To your question: I guess the shortest correct pattern is

  (pred (eq one))


Regards,

Michael.



  reply	other threads:[~2017-04-17 20:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-17 18:07 Using let-bound var inside pcase conditions Kaushal Modi
2017-04-17 20:33 ` Michael Heerdegen [this message]
2017-04-17 20:40   ` Kaushal Modi

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=87tw5mdba4.fsf@drachen \
    --to=michael_heerdegen@web.de \
    --cc=help-gnu-emacs@gnu.org \
    --cc=kaushal.modi@gmail.com \
    /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.
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).