From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: phillip.lord@russet.org.uk (Phillip Lord) Newsgroups: gmane.emacs.devel Subject: Re: The poor state of documentation of pcase like things. Date: Sat, 19 Dec 2015 21:57:22 +0000 Message-ID: <874mfenltp.fsf@russet.org.uk> References: <20151216202605.GA3752@acm.fritz.box> <87mvt859cw.fsf@russet.org.uk> <87poy2tqrc.fsf@web.de> <87mvt6nsxr.fsf@russet.org.uk> <87oadmkuwd.fsf@web.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1450562275 19794 80.91.229.3 (19 Dec 2015 21:57:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 19 Dec 2015 21:57:55 +0000 (UTC) Cc: emacs-devel@gnu.org To: Michael Heerdegen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Dec 19 22:57:43 2015 Return-path: Envelope-to: ged-emacs-devel@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 1aAPVW-0003Rg-Pm for ged-emacs-devel@m.gmane.org; Sat, 19 Dec 2015 22:57:42 +0100 Original-Received: from localhost ([::1]:38863 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAPVV-0008PN-W0 for ged-emacs-devel@m.gmane.org; Sat, 19 Dec 2015 16:57:41 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56298) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAPVI-0008P2-Vp for emacs-devel@gnu.org; Sat, 19 Dec 2015 16:57:29 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aAPVF-0005Ij-PT for emacs-devel@gnu.org; Sat, 19 Dec 2015 16:57:28 -0500 Original-Received: from cheviot12.ncl.ac.uk ([128.240.234.12]:48442) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAPVF-0005Ia-Ja for emacs-devel@gnu.org; Sat, 19 Dec 2015 16:57:25 -0500 Original-Received: from smtpauth-vm.ncl.ac.uk ([10.8.233.129] helo=smtpauth.ncl.ac.uk) by cheviot12.ncl.ac.uk with esmtp (Exim 4.63) (envelope-from ) id 1aAPVD-000230-Bz; Sat, 19 Dec 2015 21:57:23 +0000 Original-Received: from cpc6-benw10-2-0-cust45.gate.cable.virginm.net ([92.238.179.46] helo=localhost) by smtpauth.ncl.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1aAPVD-00061R-B2; Sat, 19 Dec 2015 21:57:23 +0000 In-Reply-To: <87oadmkuwd.fsf@web.de> (Michael Heerdegen's message of "Sat, 19 Dec 2015 22:09:38 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 128.240.234.12 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:196532 Archived-At: Michael Heerdegen writes: >> Not convinced. The documentation says.... >> >> =E2=80=98(pred numberp)=E2=80=99 is a pattern that simply checks that = =E2=80=98exp=E2=80=99 is a number, >> and =E2=80=98_=E2=80=99 is the catch-all pattern that matches anything. >> >> for example, which made me assume that "_" matches anything. > > Anything in a backquote is implicitly quoted, and thus should behave > like > > 'VAL matches if the object is =E2=80=98equal=E2=80=99 to VAL. > > The elements in a backquoted list in a pcase pattern are _not_ > interpreted as pcase patterns, unless unquoted. _ is not special here. > > You also can't use > > `(1 2 (pred numberp)) > > as you would expect. Why should _ be different? I can certainly see your point, and agree from a point-of-view of semantics then it makes sense. But from a point-of-view of usability, I am less convinced. "_" is different because it has no formal semantics in the rest of lisp. So, for example,=20 (funcall (lambda(_) _) 1) returns 1. Compare this with works (pcase 1 (a a)) and this which errors (pcase 1 (_ _)) So, "_" can have any semantics we like, and remain consistent. To me, I would expect this: (pcase '(1) (`(_) 'hello)) to return 'hello and yet it does not. Set against, this, I guess you are worried that with the semantics I suggest then you cannot do something like this: (pcase '(1) (`(_) 'hello) (`(1) 'goodbye)) =20=20 which now returns 'goodbye, but would return 'hello. This is a valid concern, I agree, although I think is a more minor usage (since "_" has no special semantics, how often do you want to match this!). Perhaps, it could be supported by a syntax like this: (pcase '(1) (`('_) 'hello) (`(1) 'goodbye)) =3D> 'goodbye Irrespective of whether you agree with this or not, what I would say is that the current requirement for ,_ is not obvious, and that it is a pcase "gotcha". I would say that least one concrete example in the manual of this usage, explicitly mentioning the , is a good idea. Phil