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: pcase docstring tweaks (was: Question on pcase) Date: Sun, 25 Oct 2015 02:00:48 +0200 Message-ID: <87h9lf95qn.fsf_-_@web.de> References: <83r3kmrtat.fsf@gnu.org> <87r3kl22zk.fsf@web.de> <837fmdzpf2.fsf@gnu.org> <87oafp659p.fsf@web.de> <831tclzly9.fsf@gnu.org> <87fv115t20.fsf@web.de> <20151024090146.GA1849@acm.fritz.box> <878u6spgmp.fsf@gmx.net> <20151024174719.GB2731@acm.fritz.box> <87ziz8nkue.fsf@gmx.net> <20151024192858.GC2731@acm.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1445731273 6428 80.91.229.3 (25 Oct 2015 00:01:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 25 Oct 2015 00:01:13 +0000 (UTC) Cc: Eli Zaretskii , Stephen Berman , Oleh Krehel , Emacs Development To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Oct 25 02:01: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 1Zq8kA-0002b1-4w for ged-emacs-devel@m.gmane.org; Sun, 25 Oct 2015 02:01:02 +0200 Original-Received: from localhost ([::1]:46031 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zq8k9-0004wU-Bh for ged-emacs-devel@m.gmane.org; Sat, 24 Oct 2015 20:01:01 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45081) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zq8k4-0004wC-Qr for emacs-devel@gnu.org; Sat, 24 Oct 2015 20:00:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zq8k1-0004kW-IZ for emacs-devel@gnu.org; Sat, 24 Oct 2015 20:00:56 -0400 Original-Received: from mout.web.de ([212.227.17.12]:65348) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zq8k1-0004kP-93; Sat, 24 Oct 2015 20:00:53 -0400 Original-Received: from drachen.dragon ([90.186.1.67]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0MCZlG-1ZhvGL3ppK-009MSC; Sun, 25 Oct 2015 02:00:52 +0200 In-Reply-To: <20151024192858.GC2731@acm.fritz.box> (Alan Mackenzie's message of "Sat, 24 Oct 2015 19:28:58 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-Provags-ID: V03:K0:pJNl67Es5JG2yqXzrtsZbzE8+5YWN8sQGYInl3iLlu6xNMSZm5U Sl4uLY5llWR5bk9g/zfBNJvxBLXrPtr9IU6C9xQ5CDZtzhU3PSd2MAkkr96XrJYPlRfByh/ ocXfPe9vMCIOPx1HxQrg+mGZsbVuSalPECMgmUgIuoMywYTCvSPwj9y3uiPPGoOvBxeZW5c RW1Q1N3+xSl+Ivy/p+CyQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:7T7rVkcnnrs=:TiykXr/2xfJqZmUIQoyk1I 3W1AXWWQDXTqeW4SDlnfz6tRRC7WHW1EyIii8gXik42xrM7FWGQTPKYoSKjjrFraZt+PpXwxn ZTz5E/oPU98ne6TDKRa1WfnEucKxp59F9EHXq4OFNBPEx1gi/7PekGbmEgObCfn7ZAG+V3z5V B2zpn+0iH/KcHw57jJVX2fz5tXK5o/YsOKOcFQVu1HTDMy6x96CJzCyqfq6OLCnFwqTyTMeRA W/AoLtcUHW00+cHd/4Qe4tfWwyFbvXK3sim43EQklS7CEuhKiLZrhNJ8D2v9FHCJX2W7mEHfm yxGDsLVIufBpBtDBMO2M5OQzvL1MtvCRPJW4q2oIGSq5se+dbxpMY1YH7xZyB4XzcPldPipTw JcysdQfGPqjNOK51AeXAcw9LJEs+A84IJmJ1o3qOIOQkUdlKDrqWP/0Nc94u5IinqFKdrWsmN syOF4LVJAlhZAbAP2h8FzqSH5xC4UGdibHJoQO6qWtlAuJ6WN6af/TPUMKIDcoeYaJ9jYP3yh Lfm+sBwYSjbszFSSnNd52hqPqWe3mL+o158BzyHw795M/weJ14kvQZmCsEER+PzSu/Uecwptt oQEHLbrzy4bOULaeHqyrTzI13+20rKwZU9Nr8GgTD039UMwx/dmK/laa+5mkSUvdkMpRdE3Og BFJGsvf0HdrFfDrtXsuJifNy6pqSR31oJpGICCjlzYWo9v+uz54X4wJLnucXqxUjVzzMvtNnd cXEXVzQpanP3W+vpulaYMV9DuCIHX8tsnSbQV1QGzkSpEWtklsrMC8A3AGPDCxumF8QttVWa X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.17.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:192594 Archived-At: --=-=-= Content-Type: text/plain Alan Mackenzie writes: > But I honestly think it's time for our discussion to cease. We've > unwittingly descended into bikeshedding, and we're not going to be > helping Michael Heerdegen much with it. But thanks for the discussion > anyway! I can only thank everyone who joined the discussion as well! I'll think carefully about all comments, and make the corrections. Let's continue with the `pcase' docstring. I think it's already quite good. Here is a patch emphasizing that EXP is actually evaluated (I think that is not evident) and some more or less cosmetic changes. Is it clear then? --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=pcase.patch *** /tmp/ediff17164yyt 2015-10-25 01:54:53.175155728 +0200 --- /home/micha/software/emacs/lisp/emacs-lisp/pcase.el 2015-10-25 00:35:23.999856799 +0200 *************** *** 107,113 **** ;;;###autoload (defmacro pcase (exp &rest cases) ! "Perform ML-style pattern matching on EXP. CASES is a list of elements of the form (PATTERN CODE...). Patterns can take the following forms: --- 107,113 ---- ;;;###autoload (defmacro pcase (exp &rest cases) ! "Eval EXP and perform ML-style pattern matching on that value. CASES is a list of elements of the form (PATTERN CODE...). Patterns can take the following forms: *************** *** 115,123 **** SYMBOL matches anything and binds it to SYMBOL. (or PAT...) matches if any of the patterns matches. (and PAT...) matches if all the patterns match. ! \\='VAL matches if the object is `equal' to VAL ATOM is a shorthand for \\='ATOM. ! ATOM can be a keyword, an integer, or a string. (pred FUN) matches if FUN applied to the object returns non-nil. (guard BOOLEXP) matches if BOOLEXP evaluates to non-nil. (let PAT EXP) matches if EXP matches PAT. --- 115,123 ---- SYMBOL matches anything and binds it to SYMBOL. (or PAT...) matches if any of the patterns matches. (and PAT...) matches if all the patterns match. ! \\='VAL matches if the object is `equal' to VAL. ATOM is a shorthand for \\='ATOM. ! when ATOM is a keyword, an integer, or a string. (pred FUN) matches if FUN applied to the object returns non-nil. (guard BOOLEXP) matches if BOOLEXP evaluates to non-nil. (let PAT EXP) matches if EXP matches PAT. *************** *** 131,141 **** which is the value being matched. So a FUN of the form SYMBOL is equivalent to one of the form (FUN). FUN can refer to variables bound earlier in the pattern. - FUN is assumed to be pure, i.e. it can be dropped if its result is not used, - and two identical calls can be merged into one. E.g. you can match pairs where the cdr is larger than the car with a pattern like \\=`(,a . ,(pred (< a))) or, with more checks: \\=`(,(and a (pred numberp)) . ,(and (pred numberp) (pred (< a)))) Additional patterns can be defined via `pcase-defmacro'. Currently, the following patterns are provided this way:" --- 131,141 ---- which is the value being matched. So a FUN of the form SYMBOL is equivalent to one of the form (FUN). FUN can refer to variables bound earlier in the pattern. E.g. you can match pairs where the cdr is larger than the car with a pattern like \\=`(,a . ,(pred (< a))) or, with more checks: \\=`(,(and a (pred numberp)) . ,(and (pred numberp) (pred (< a)))) + FUN is assumed to be pure, i.e. it can be dropped if its result is not used, + and two identical calls can be merged into one. Additional patterns can be defined via `pcase-defmacro'. Currently, the following patterns are provided this way:" --=-=-= Content-Type: text/plain Regards, Michael. --=-=-=--