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: Mon, 21 Dec 2015 10:15:50 +0000 Message-ID: <87si2wnm3t.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> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1450692978 12464 80.91.229.3 (21 Dec 2015 10:16:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 21 Dec 2015 10:16:18 +0000 (UTC) Cc: michael_heerdegen@web.de, emacs-devel@gnu.org To: Richard Stallman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 21 11:16:09 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 1aAxVh-0002Kw-BW for ged-emacs-devel@m.gmane.org; Mon, 21 Dec 2015 11:16:09 +0100 Original-Received: from localhost ([::1]:43853 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAxVg-0006ZP-Od for ged-emacs-devel@m.gmane.org; Mon, 21 Dec 2015 05:16:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47887) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAxVU-0006Z4-Jb for emacs-devel@gnu.org; Mon, 21 Dec 2015 05:15:57 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aAxVT-0002wu-OX for emacs-devel@gnu.org; Mon, 21 Dec 2015 05:15:56 -0500 Original-Received: from cheviot12.ncl.ac.uk ([128.240.234.12]:34586) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAxVQ-0002vc-15; Mon, 21 Dec 2015 05:15:52 -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 1aAxVP-00087M-AI; Mon, 21 Dec 2015 10:15:51 +0000 Original-Received: from jangai.ncl.ac.uk ([10.66.67.223] helo=localhost) by smtpauth.ncl.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1aAxVP-00024z-3b; Mon, 21 Dec 2015 10:15:51 +0000 In-Reply-To: (Richard Stallman's message of "Mon, 21 Dec 2015 00:04:21 -0500") 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:196593 Archived-At: Richard Stallman writes: > [[[ To any NSA and FBI agents reading my email: please consider ]]] > [[[ whether defending the US Constitution against all enemies, ]]] > [[[ foreign or domestic, requires you to follow Snowden's example. ]]] > > > It matches anything (like a variable) but does not actually bind a variable. > > Alas, that's the half of the answer that I already knew. > What I don't know is, how do you _write_ the use of _? > That seemed self-contradictory in the text that was posted. > > Can someone show me some properly working examples of _ in pcase > and say what they do? Okay. This is the simplest use and it returns 'hello (pcase 1 (_ 'hello)) It differs from a normal symbol because this: (pcase 1 (a a)) evals to 1, while this (pcase 1 (_ _)) errors with "void variable". That is `_' is not bound, unlike a. So `_' is more than just convention. Inside a list, though, it needs to be comma'd. So: (pcase '(1 2 3) (`(,a 2 3) 'hello)) (pcase '(1 2 3) (`(,_ 2 3) 'hello)) both return `hello' (the former binding `a', the latter not binding `_'). The question is how should this form behave. (pcase '(1 2 3) (`(_ 2 3) 'hello)) Currently, it returns `nil' because `_' matches the symbol `_' not anything. Obviously, this is useful if you want to match the symbol `_'. But I think it's unintuitive. Even if everyone agrees it is wrong, if it is fixable, I do not know. I suspect it's probably too late in the day for the emacs-25. Phil