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 15:59:17 +0200 Message-ID: <87si5165ze.fsf@web.de> References: <871tcngdv2.fsf@gmail.com> <87k2qe1u09.fsf@web.de> <83r3kmrtat.fsf@gnu.org> <87k2qdeqym.fsf@gmail.com> <87lhat22pv.fsf@web.de> <87ziz9dadv.fsf@gmail.com> <87wpud68e6.fsf@web.de> <87k2qdd8c7.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1445609040 20323 80.91.229.3 (23 Oct 2015 14:04:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 23 Oct 2015 14:04:00 +0000 (UTC) Cc: emacs-devel@gnu.org To: Oleh Krehel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Oct 23 16:03:49 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 1Zpcwe-0002V0-PN for ged-emacs-devel@m.gmane.org; Fri, 23 Oct 2015 16:03:48 +0200 Original-Received: from localhost ([::1]:38698 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zpcwe-0001xY-A2 for ged-emacs-devel@m.gmane.org; Fri, 23 Oct 2015 10:03:48 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpcsP-00036C-7u for emacs-devel@gnu.org; Fri, 23 Oct 2015 09:59:26 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZpcsL-0000y2-V9 for emacs-devel@gnu.org; Fri, 23 Oct 2015 09:59:25 -0400 Original-Received: from mout.web.de ([212.227.17.12]:59281) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpcsL-0000xv-PP for emacs-devel@gnu.org; Fri, 23 Oct 2015 09:59:21 -0400 Original-Received: from drachen.dragon ([90.186.0.245]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0M1X9B-1aehA63uzx-00tW4y; Fri, 23 Oct 2015 15:59:20 +0200 In-Reply-To: <87k2qdd8c7.fsf@gmail.com> (Oleh Krehel's message of "Fri, 23 Oct 2015 15:26:32 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-Provags-ID: V03:K0:uGt4krEr9183QjD1IcOKIwqkXan/28CBf6xOSwG8ToehiKva+s7 oq07iTKzEyylbXVxDXvQw/Fn7pf2Eg2wAqXdnxq+PYmqbWHNjLJOUJZEFvm85Vi+iS5WJjJ UYgdMhE9txg86auIMWAClbYS5n73ArAV42fSUDOKphsjP1xf81BNTchwIUJjMT2+n3rI3Uk 7b53o3jVQVZ475P9ejRDw== X-UI-Out-Filterresults: notjunk:1;V01:K0:qYRfDSR+rmI=:HgJ7HcCXgTE5LU4h2w/0jS ggtGQl1pWmILRJOr5/EvvoxBe/4EsB+W4+2MjaQH2BZIdv+ev5XBKqiFfW1RnaaCwLFK8fWSX 1ByfPhS9ZNeMKNeW5WM8zD4hSfEMJJCFMJRGJx+A5iOErLKY2XKQZDat6xiF0dyi7SANkKovb B46T+n+1Jz/lp7VHLAdmFiYREumKq+N+YN5jaHfyC1QhLWk+YNdj9V5giowmsRvrWt/4wg8W8 +DFdSqE7FL6Y/8aPJV6xp6uA9l/BI7/SOr5Jqp3y5bry+EscsKD4CndS66xA8UXd2raVqglRX ejQ8mFsSclaG2HH8onNK6XO5jxh36xea6PjoVeZdEhhEEqxm4LEHTQ6+wZFymlpZGNFGfu2XI FTXUt4F3Fz8dY8+LIrQ7Qc2eCnugb4Zc6NGPOktKZjTpfA5JgqoSRf4sdS9Kk/vUlIfKLPMwO br9Yz5hA1xF1kGvyuAbfu1jSORJM/nRsb5cNuhsTE5J7yE64ZaeZL0CPC8U8kG5icSsd3hUX6 3OPimWS/5vJClJNZfFBQUzbr5m94LGuPlBDPPC9M3Wl9Ybb/lTNfmki+4y0aHXuGC+1kTweKv wsn+CgwbxYaM5Vfo4hdzAePuIH17iJy6Z/ETeUoWr8AVSsLD29tWGdW+JyMdO7raZ24TcJ4YA Ds+xJtw77F/R4rBtUN/Jc6lvneNHkw5tZPe/6jnAUfw/uj/xTxBihGVGc1J4s49B5/wpWdjrp HdA0CRyr7TEW8vwa+s2sly9LgVWP44mLTyGdxX6mTPQUZsSVP2KvKjqJ1RkkxW2pcHMrpKwk 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:192489 Archived-At: Oleh Krehel writes: > This can all be done in-place without producing extra buffers. A simple > "C-c C-e" on a branch should either: > > (message "the branch doesn't match") > > or e.g.: > > (progn > (setq hookfun (car res)) > (setq start (nth 0 (cdr res))) > (setq end (nth 1 (cdr res))) > (setq collection (nth 2 (cdr res))) > (setq plist (nthcdr 3 (cdr res))) > (message "match")) That doesn't make sense to me. In real-life code, you have free variables, and whether a branch matches depends on the current environment. E.g. if you have (pcase x (1 t) (_ nil)) and you put the cursor after the "1" pattern and hit C-c C-e, what would you expect to happen? Whether that branch matches depends on the current binding of x. > Instead, (pcase-demystify-pattern '`(,hookfun . (,start ,end > ,collection . ,plist))) gives: > > (if (consp -tested-expression-) > (let* ((x (car -tested-expression-)) > (x (cdr -tested-expression-))) > (if (consp x) > (let* ((x (car x)) > (x (cdr x))) > (if (consp x) > (let* ((x (car x)) > (x (cdr x))) > (if (consp x) > (let* ((x (car x)) > (x (cdr x))) > (progn > (-bind- plist x) > (-bind- collection x) > (-bind- end x) > (-bind- start x) > (-bind- hookfun x))) > nil)) > nil)) > nil)) > nil) The Lisp printer discarded relevant information here, please do (setq print-gensym t) (setq print-circle t) when printing a result of `pcase-demystify-pattern'. After you have done that, you exactly see how matching is done. > Which is indeed close to what I need. I guess `-bind-` should be some > macro that pops and does a `set'. I'm just not sure that this is exactly > true, and will work for all patterns. The only thing that makes sense to me would be to make `edebug' let you step into a pattern. AFAICT that would be a very hard work. Michael.