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: Sun, 20 Dec 2015 18:51:54 +0000 Message-ID: <8737uxgdh1.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> <874mfenltp.fsf@russet.org.uk> <87oadltfcc.fsf@web.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1450637533 25790 80.91.229.3 (20 Dec 2015 18:52:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 20 Dec 2015 18:52:13 +0000 (UTC) Cc: emacs-devel@gnu.org To: Michael Heerdegen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Dec 20 19:52:04 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 1aAj5Q-0005bx-9T for ged-emacs-devel@m.gmane.org; Sun, 20 Dec 2015 19:52:04 +0100 Original-Received: from localhost ([::1]:41682 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAj5P-0003CO-La for ged-emacs-devel@m.gmane.org; Sun, 20 Dec 2015 13:52:03 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAj5M-0003CG-Q3 for emacs-devel@gnu.org; Sun, 20 Dec 2015 13:52:01 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aAj5J-0001Oh-Kb for emacs-devel@gnu.org; Sun, 20 Dec 2015 13:52:00 -0500 Original-Received: from cheviot22.ncl.ac.uk ([128.240.234.22]:37048) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAj5J-0001Ob-Ek for emacs-devel@gnu.org; Sun, 20 Dec 2015 13:51:57 -0500 Original-Received: from smtpauth-vm.ncl.ac.uk ([10.8.233.129] helo=smtpauth.ncl.ac.uk) by cheviot22.ncl.ac.uk with esmtp (Exim 4.63) (envelope-from ) id 1aAj5H-0002YV-Et; Sun, 20 Dec 2015 18:51:55 +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 1aAj5H-0002zJ-E4; Sun, 20 Dec 2015 18:51:55 +0000 In-Reply-To: <87oadltfcc.fsf@web.de> (Michael Heerdegen's message of "Sun, 20 Dec 2015 14:33:07 +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.22 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:196564 Archived-At: Michael Heerdegen writes: > phillip.lord@russet.org.uk (Phillip Lord) writes: > >> 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". > > You know, I wanted to make the same suggestion a year ago. ,_ looks > weird, I see all your arguments, they are all valid. > > But how would that fit into the semantics we have? _ is a pcase > pattern. You would like it to be also a valid QPAT, matching anything. I don't know. I am thinking of it from a point-of-view of the syntax I would like as a user, rather than the semantics I would use to achieve this. I do worry that the syntax of pcase is too complex. As an example compare dash.el and pcase: (-let [(a b _) '(1 2 3)] (list a b)) (pcase-let ((`(,a ,b ,_) '(1 2 3))) (list a b)) I've chosen an extreme example here, but the pcase version has a lot of punctuation (and worth remembering however familiar the macro expert is with punctuation not all emacs-lisp programmers are). Set against this, dash is imperfect in it's handling of "_". Compare: (-let [(a b _) '(1 2 3)] (list a b _)) (pcase-let ((`(,a ,b ,_) '(1 2 3))) (list a b _)) The former returns "(1 2 3) while the later errors with "No such var". > This would mess up the semantics to the worse: `_ would > then be a pcase pattern matching anything. Should '_ also match > anything? But how to match the symbol _ then? If not, why should `_ be > different from '_ when there is no unquoting involved? > > Or should _ as a QPAT only behave different when used "not at toplevel"? > This would be horribly inconsequent: We would get two different types of > QPATs: toplevel QPATS, and non-toplevel-QPATS. That would confuse > people even more, a pain to explain and to internalize. I thought we were not going to mention q-patterns any more! I think that too much of the implementation semantics is poking through into the syntax. I suspect no one would notice if "_" matched anything inside a backquoted list, because it feels natural. Phil