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

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

bug#31311: 27.0; doc of `pcase'


From: Michael Heerdegen
Subject: bug#31311: 27.0; doc of `pcase'
Date: Sat, 12 May 2018 15:54:18 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Thien-Thi Nguyen <ttn@gnu.org> writes:

>   a.  (pcase t   ('t   'true))  => true
>   b.  (pcase nil ('nil 'false)) => false
>   c.  (pcase t   (t    'true))  => true
>   d.  (pcase nil (nil  'false)) |= ERROR: Unknown pattern ‘nil’
>
> and wonder if/how to approach this corner case in the docs.  I
> suppose before anything, i'd like to confirm that c. and d. are
> correct and intended (i believe a. and b. to be correct and
> intended, but maybe i'm missing something there, too!).

That's all correct and intended - see 3ef31167.  t was originally
intended as catchall pattern equivalent to _ but has been deprecated
(since it was confusing).  Try e.g.

  (pcase nil
   (t t))

You get a message when you use it, but when evaluating and not when
compiling (so you must look in the *Messages* buffer - I don't think
this is intended...).  A catch-nothing pattern is not useful, so nil is
just invalid.

I once asked Stefan if t and nil could be handled like the ATOM case,
but he didn't want to do this (backward compatibility, don't recall).


Michael.





reply via email to

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