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: Question on pcase Date: Fri, 23 Oct 2015 23:01:46 +0200 Message-ID: <877fmd5mf9.fsf@web.de> References: <871tcngdv2.fsf@gmail.com> <87k2qe1u09.fsf@web.de> <83r3kmrtat.fsf@gnu.org> <87r3kl22zk.fsf@web.de> <837fmdzpf2.fsf@gnu.org> <87oafp659p.fsf@web.de> <831tclzly9.fsf@gnu.org> <87fv115t20.fsf@web.de> <562A91AA.3030208@cumego.com> 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 1445634142 5534 80.91.229.3 (23 Oct 2015 21:02:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 23 Oct 2015 21:02:22 +0000 (UTC) Cc: Emacs Development To: =?utf-8?Q?Przemys=C5=82aw?= Wojnowski Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Oct 23 23:02:13 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 1ZpjTQ-0005Vn-5g for ged-emacs-devel@m.gmane.org; Fri, 23 Oct 2015 23:02:04 +0200 Original-Received: from localhost ([::1]:41632 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpjTP-00089k-7y for ged-emacs-devel@m.gmane.org; Fri, 23 Oct 2015 17:02:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48055) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpjTM-00089f-3a for emacs-devel@gnu.org; Fri, 23 Oct 2015 17:02:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZpjTH-0006J1-0p for emacs-devel@gnu.org; Fri, 23 Oct 2015 17:02:00 -0400 Original-Received: from mout.web.de ([212.227.17.12]:51608) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpjTG-0006Ip-Qr for emacs-devel@gnu.org; Fri, 23 Oct 2015 17:01:54 -0400 Original-Received: from drachen.dragon ([90.186.0.245]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0LdF4n-1aGEeK0VH7-00iPzX; Fri, 23 Oct 2015 23:01:50 +0200 In-Reply-To: <562A91AA.3030208@cumego.com> (=?utf-8?Q?=22Przemys=C5=82aw?= Wojnowski"'s message of "Fri, 23 Oct 2015 21:59:38 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-Provags-ID: V03:K0:mDHjJSUcm68tLGWr7iFgJTvHGBoZN6BXGRTtIvVrS/5U2ov6rE7 UkA1rlc5y1BXDOcx41II4DfUCXR7Y65mggt7364pK6sMtoLL4ciQapkKx+P4E2lLne571qs W6kRNSeX2co2K/7aODcvQcvHSCAlLGcs1+d47GUi6XUjqZtUxx5frTJnxwkloMnTcLgJ7JY 6wTkQBowNKsavFNLZWxpQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:dT+rw0aD4jc=:ySaJ2Iaqv4jlGkxTNyhFC5 oC6eOJgjU3oSZ0+NsWo4oG8+gKG/3c8Cw91R4vjtbAR13FQFEvrXcxzG9gOsMvWaB6g+JXLf4 /395CiGHOzKKCsOtECGVAHK+BYULCAmIPhqH9XVguRaXXqA9rHG9ohCK6fO8JFpf4HYDfssgK 4touedgHFoTVtChTqpiTGYFmscXTVozTBPvBhmGvkN8nIS+fuKp6nEqwqHnznSh8yg7er9jNV pq75VZT0XwQvVJAc39JxYqF9VQFYDAw6aFwGa39nmbMF8aP0U/Yf9BiJqRRhjOKy8l9P9JnLz Z64GHssLZN3r0OiOv4A+vhAYiX89YkCQedhDZzANl9RuXke149//aPohU/O5Qli/RasO1vxnA Qe9iKBBLFG1iIxs1wKZiiGFNN8FIPbSZSPWW/vUcBcZSDdhhEEYRDHWibH0aeODkur0Q+xR6J UGiyGA5lELf78mjGrGBqCWwQ1HNgCQZEuLlDBSyLBRQU+dHCDYM0QBeSlh0rLpTDNbeXdKrzf Vd2qY6GDriI2S4exL2+tXpgVgs+NC0l0v93UkvapYL45fogGshhJJO7aPlgL+4j9FJHLexsA4 lySCKZGE1DeHzM6D/lPY7GaQcTtpK3KXtaXHxjhfmZrdEgvEElAfg7CFNEo++K+yhFwrKK3PG 2J8VVL0jLIa1jNW8SuQcArfP73Gs58Ifvbb3hOLXOFaquRhvRE2ZTw5ScHzIq31qcH3E+RvOk D7alx2sfYWbywjNKQpgQVpzhTvrNsKM4lP9++DFPNl6iwbGkuKaO5lw6DODXemq8GvuyCvk3 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:192522 Archived-At: Przemys=C5=82aw Wojnowski writes: > line 103: > ;; that's the case only for the string "Hallo" (why would it not be > ;; useful to leave out the quote before the symbol `a'? > > Is it a question to the reader or you just forgot to remove? A question to the reader - forgetting to quote a symbol is a common pitfall. If the user works the reason out for herself, it is probably easier to remember. > --------------- > line 136: > ;; If matching any pattern established a variable binding, you can > ;; refer to these bindings in the following patterns. > > Shouldn't end with "[...]the following patterns in the same branch."? > Without this there's a little confusion on whether the binding is also > available in the below branches too. Good catch, indeed. > --------------- > Around line 177 - (let PAT EXP) example: > (pcase x > ((and (pred numberp) > (let (pred (lambda (x) (< 5 x))) (abs x))) > t) > (_ nil)) > IMHO it would be better to simplify this example to contain only "let" pa= rt: > (pcase x > ((let (pred (lambda (x) (< 5 x))) (abs x)) > t) > (_ nil)) > And in explanation write order of evaluation: result of EXP(x) is > passed to PAT. Anyway, this part wasn't clear to me. Mmh, so this part is a bit unclear. Thanks, maybe I can even find a better suited example. > What are some good (concrete) use cases for the pcase? When would you > suggest to use it instead of cond or other similar constructs? IME you know when you need it after having learned it. The first times where you use it in your code will probably be cases where a `case' or a `cond' nearly fit, but is not sufficient. E.g. where a `cl-case' would be appropriate for most branches but you need to test a condition in one branch. Start like that, and keep in mind that `pcase' is in your toolbox while coding. For concrete use cases - just see the Emacs sources! But it's hard to describe the typical use case for `pcase' as it is hard to describe a typical use case for a tool chest. Thanks for your feedback! Michael.