Subject: Re: bug#31311: 27.0; doc of `pcase'

From: Michael Heerdegen <[email-masked]>
Date: Sat, 12 May 2018 15:54:18 +0200

Thien-Thi Nguyen <[email-masked]> 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.