From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.devel Subject: Re: The poor state of documentation of pcase like things. Date: Sun, 27 Dec 2015 00:17:04 +0100 Message-ID: <87vb7kajgv.fsf@web.de> References: <20151216202605.GA3752@acm.fritz.box> <87io3m60bq.fsf@web.de> <877fk1nnk0.fsf@web.de> <8760zlue3j.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1451171848 8568 80.91.229.3 (26 Dec 2015 23:17:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 26 Dec 2015 23:17:28 +0000 (UTC) Cc: emacs-devel@gnu.org To: Aaron Ecay Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Dec 27 00:17:19 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 1aCy5O-0005ya-Mh for ged-emacs-devel@m.gmane.org; Sun, 27 Dec 2015 00:17:18 +0100 Original-Received: from localhost ([::1]:40095 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aCy5N-0004t4-OM for ged-emacs-devel@m.gmane.org; Sat, 26 Dec 2015 18:17:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59957) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aCy5J-0004su-TA for emacs-devel@gnu.org; Sat, 26 Dec 2015 18:17:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aCy5G-0001EE-LS for emacs-devel@gnu.org; Sat, 26 Dec 2015 18:17:13 -0500 Original-Received: from mout.web.de ([212.227.15.14]:58434) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aCy5G-0001E8-CQ for emacs-devel@gnu.org; Sat, 26 Dec 2015 18:17:10 -0500 Original-Received: from drachen.dragon ([90.186.2.151]) by smtp.web.de (mrweb003) with ESMTPSA (Nemesis) id 0LvSQV-1aLBA03hgZ-010blE; Sun, 27 Dec 2015 00:17:08 +0100 In-Reply-To: <8760zlue3j.fsf@gmail.com> (Aaron Ecay's message of "Sat, 26 Dec 2015 15:52:48 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-Provags-ID: V03:K0:XcW4srvJm3G8SEQX9VxDzRE4JBWIMQJ5aM0iazJFsS8B03tU6g7 vDeC30DeyC2LgICQHI6a5Whxpo5V+JqT9KNzwm0pYC78xkWkkTriCojEKNg5igvLpiaDhzY zxhXDlPECcmEIOehNLe3CRvN2h9jMHX0IzdtFTLdQBn2V0j7cGKNoOPT4vxkWQvRLb+PAuY PASfLlTZadAyu7h4Gle2g== X-UI-Out-Filterresults: notjunk:1;V01:K0:1V2KpzzxQ0A=:P3JcgBAc3ZvjuK1iX76COm Sc3rZqYIkgc5+bHDrSnVfKUEVDkgUbUSIs357GzSqHT+66AI2ncBWNXrwquNkwRaAtMvK9WGA GwpMs0xmlgPsY/w5U+7wCQ3gYsUeN5HLpJaVgTtqm254Pf/ZzgbtWslq2Z/hsPc0TT8VggP+A FwxUsHPZghsVANRw7+4TQYqD2ckT9GApiQsX6j04dFHMW6Q1DNk8VWz6raJRkK+aIbY3Cpwli hRDPs8PpzoZfwq4M55QEE6Uape2iD3psp2dynNkhgIXwfOg/n7r8Tq/JKLzBlGABhoSoiTHpe neJtvx8vm9dmd2TnFcbuF2JMpWgWLUcv8EAMsNLxOytPUn9BW83Kt53DZtDZQsLiBiqhFv0Og 6zLX8V2hqOMBxOocpc8kHQzoubPYUmTIPSIWFLxDvRBb2zdvYPQ7yRoQ0jcuWoy4KCMDMSJIi 5XyP06wM06SR/XHzU9Nlr5ciB4UcwaP+EIUUqkm+Sv9VOi0m0R2CoBmSFTIo0Ymdsc7ga3vXo cCFTwG/7ml8D+Bz/0d5oqaCObK0FxNKdMRyVIIOPX1iTYZ3yVzNN3ZZwFa3+CZc8YPuHn5oso 2EG5hEh2Sq/ubXwMFfXGvm6AkljrjxMFoHCsqFn32ddFAgqKJN+BhkhjIVCyGoUwahORns8il eLnURY7/mfWvqor+bPolGA/3VYAtjOU7FlaCNdD8A3QUDsD/twsydt5b3TtmBKQ8voYcTCKXo if3WG67Fm02fnEKngN5BuBVFiB0eCzYFprkWOHQVwtdqLlHhLqwl6P3vu6wTB1d+u/DS+fOC X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.15.14 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:196941 Archived-At: Aaron Ecay writes: > Atoms (strings, numbers, and keywords) are simultaneously patterns and > qpatterns. That is, one writes `(1 2) and not `(,1 ,2) to match a list > containing 1 and 2 (though actually either form works). Why could _ not > also be shared between the pattern and qpattern classes? If you consider that ` quotes any element in its argument list unless it is explicitly unquoted (that's how it actually works), an ATOM becomes 'ATOM, which is equivalent to just ATOM as a pattern. That one can avoid the comma before atoms inside ` reflects that equivalence on a different level. There are more such analogies (for example `something and 'something are equivalent if something doesn't include a comma) and it's good that they are there, because it makes the grammar easier to memorize, aka "build a mental model". Maybe you can call this "aesthetics" in this regard. Making _ a qpattern would break the logic in the design: '_ matches the symbol _, not anything as the _ pattern does (disjointness of qpatterns and pcase patterns is a different thing, and I think nobody cares about that). Making _ a qpattern wouldn't break pcase, but it would make the thing less consistent, because there would be a fracture somewhere in the logic, e.g. if _ is a qpattern matching anything, `_ and '_ would have different semantics as pcase patterns (the first would be equivalent to _), or such things. I would agree to do this anyway if there was a good reason. Saving a comma or fitting the expectations of users that haven't yet completely understood the semantics (I don't mean Phillip by that, I mean users who want to learn the thing) is not a sufficing reason for obfuscating the logic behind the design, I think. Another thing is that I think, and that's what we want to emphasize in the docs, that qpatterns are conceptually a different thing than pcase patterns. Actually, the term "qpattern" has not much meaning at all, it is only used as a helper to describe the grammar of ` (because it is recursive, but actually, the grammar is very simple). A qpattern is either an expression that is compared with equal, or a placeholder for a real pattern via unquoting. That's all. If the description of ` in pcase would be less formal and e.g. more like the doc of `backquote', we probably would not even have a name for that. Anyway, I think it's conceptually a bad thing to merge those two quite different things. Just my personal opinion of course. I've worked with pcase quite a lot now. It took some time until I had internalized the concept (which is why I think it's important to keep it simple). If others who have used the tool quite regularly do think it would be a good idea to make _ a qpattern, let's do it. But I think we should not hurry modifying a thing in a way which at the first look seems like a good idea, and we may regret later. Sorry for the prose, this was more than you had asked for. Regards, Michael.