From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.bugs Subject: bug#20784: 25.0.50; pcase documentation on t and nil Date: Thu, 11 Jun 2015 15:18:28 +0200 Message-ID: <87r3pitmcb.fsf@web.de> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1434028780 24062 80.91.229.3 (11 Jun 2015 13:19:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 11 Jun 2015 13:19:40 +0000 (UTC) Cc: Artur Malabarba , 20784@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jun 11 15:19:30 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Z32O0-0007pu-UV for geb-bug-gnu-emacs@m.gmane.org; Thu, 11 Jun 2015 15:19:13 +0200 Original-Received: from localhost ([::1]:46888 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z32Nz-0002MH-ON for geb-bug-gnu-emacs@m.gmane.org; Thu, 11 Jun 2015 09:19:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58939) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z32Nv-0002Ji-0y for bug-gnu-emacs@gnu.org; Thu, 11 Jun 2015 09:19:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z32Nq-0005pl-Rf for bug-gnu-emacs@gnu.org; Thu, 11 Jun 2015 09:19:06 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:36006) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z32Nq-0005pS-Ej for bug-gnu-emacs@gnu.org; Thu, 11 Jun 2015 09:19:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Z32Np-0003nO-RQ for bug-gnu-emacs@gnu.org; Thu, 11 Jun 2015 09:19:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Heerdegen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 11 Jun 2015 13:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20784 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 20784-submit@debbugs.gnu.org id=B20784.143402873014571 (code B ref 20784); Thu, 11 Jun 2015 13:19:01 +0000 Original-Received: (at 20784) by debbugs.gnu.org; 11 Jun 2015 13:18:50 +0000 Original-Received: from localhost ([127.0.0.1]:50466 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z32Nd-0003mw-Rg for submit@debbugs.gnu.org; Thu, 11 Jun 2015 09:18:50 -0400 Original-Received: from mout.web.de ([212.227.17.11]:57994) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z32Nb-0003mi-Bo for 20784@debbugs.gnu.org; Thu, 11 Jun 2015 09:18:48 -0400 Original-Received: from drachen.dragon ([90.187.158.178]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0LbrZ2-1ZUR691vme-00jIrr; Thu, 11 Jun 2015 15:18:39 +0200 In-Reply-To: (Stefan Monnier's message of "Wed, 10 Jun 2015 23:07:35 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-Provags-ID: V03:K0:Rc2fpT9wV/tHz4bEmXGf05xjCJgL2H8ddumlHvk5z41XWmuzqIJ lhflZY0n6VLg78G50SPhdFOpO4KQcBvX0JLP+wpkgE26FU/+9vfugLsAGbGNfBPCybE1Cpv rAbSonR9B/AqblMT+AfLiHQ6HHoO0uUSNSTCDX27ISRs/lOjJXFpCtakFLNw+Gg+Y8LxFUQ u+JT9hbUEL6pQiY2XXdRg== X-UI-Out-Filterresults: notjunk:1; X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:103822 Archived-At: Stefan Monnier writes: > > SELFQUOTING matches itself. This includes keywords, numbers, and > > strings. > > > However, that doesn't apply to t and nil, instead, they are covered by > > the SYMBOL clause. > > I think the problem is in the wording: t and nil are neither keywords, > nor numbers, nor strings, which is why they aren't treated as > SELFQUOTING. IOW the wording shouldn't say "including" but make it > clear that these are the (currently) only accepted selfquoting entities. > E.g. vectors (and friends) aren't considered as SELFQUOTING by > pcase either. Just an opinion from another user: I think the semantic of SELFQUOTING is so non-obvious and non-intuitive that it's not worth it to confuse people who learn pcase with it, for the sake that it's more or less the same as the pattern 'VAL, or a subset from it: SELFQUOTING applies to some atomic expressions that eval to themselves, to others not. SELFQUOTING "matches itself", which again depends on the kind of thing. It doesn't always mean `eq' (as the wording "itself" suggests), because strings don't just match only themselves but any other `equal' string. But it also doesn't mean "equal" because in the case of numbers, comparison is done with `eq': (pcase 5.0 (5 5) (5.0 5.0)) => 5.0 The case of t is especially non-obvious; it's neither treated as SELFQUOTING nor as SYMBOL, but as a pattern matching anything. While `t' meaning "applies always" makes sense in `cond', because there the right sides are interpreted as booleans, it can be IMHO confusing to beginners in pcase because it could make you think that pcase is about booleans, but it's about pattern matching. I found myself trying stuff like (pcase expr ((and x (symbolp x)) (symbol-name x))), maybe having the `t' pattern in mind? And `nil' OTOH is different again. It is not interpreted as "applies never", but raises an error when used ("applies never" could make sense when the code is generated by a macro). I think I would consider to trivialize the semantic, merging the SELFQUOTING and 'VAL case. I would remove the SELFQUOTING thing as it is now. I would keep the semantic of 'VAL as it is now, as it is perfectly clear. To substitute the SELFQUOTING thing, we could allow something like ATOM - which can be any atomic expression that is not a symbol that can be bound - and make it simply an abbreviation for 'ATOM. (FWIW, unifying `ATOM and 'ATOM would IMHO also be worth it; currently 'ATOM is compared always with `equal', whereby `ATOM is compared with `equal' for strings and `eq' else. You can always use guard when you want a different comparison predicate.) I know that would all would break existing code, but it would make pcase easier to understand and to learn. Just my two cents. Regards, Michael.