GNU bug report logs -
#31311
27.0; doc of `pcase'
Previous Next
Reported by: Drew Adams <drew.adams <at> oracle.com>
Date: Sun, 29 Apr 2018 16:04:02 UTC
Severity: wishlist
Found in version 27.0
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Thien-Thi Nguyen <ttn <at> 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.
This bug report was last modified 3 years and 23 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.