help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Using let-bound var inside pcase conditions


From: Michael Heerdegen
Subject: Re: Using let-bound var inside pcase conditions
Date: Mon, 17 Apr 2017 22:33:39 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Kaushal Modi <address@hidden> 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 via email to

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