From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oleh Krehel Newsgroups: gmane.emacs.devel Subject: Re: Question on pcase Date: Tue, 27 Oct 2015 09:42:33 +0100 Message-ID: <87egggya6e.fsf@gmail.com> 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> <87io5tzkt8.fsf@gmail.com> <87fv0xd2jr.fsf@web.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1445935352 29021 80.91.229.3 (27 Oct 2015 08:42:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 27 Oct 2015 08:42:32 +0000 (UTC) Cc: Eli Zaretskii , Emacs Development To: Michael Heerdegen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 27 09:42:27 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 1Zqzpp-0006QV-9J for ged-emacs-devel@m.gmane.org; Tue, 27 Oct 2015 09:42:25 +0100 Original-Received: from localhost ([::1]:58145 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zqzpo-0002hA-MK for ged-emacs-devel@m.gmane.org; Tue, 27 Oct 2015 04:42:24 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZqzpU-0002dU-Qr for emacs-devel@gnu.org; Tue, 27 Oct 2015 04:42:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZqzpT-0001zU-JZ for emacs-devel@gnu.org; Tue, 27 Oct 2015 04:42:04 -0400 Original-Received: from mail-wi0-x236.google.com ([2a00:1450:400c:c05::236]:35587) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZqzpT-0001zP-Dg; Tue, 27 Oct 2015 04:42:03 -0400 Original-Received: by wicll6 with SMTP id ll6so148541943wic.0; Tue, 27 Oct 2015 01:42:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=UldPO2jiMFbJbgWgdfmNk2a3w5ZVggG0vAOZ6ANFB/o=; b=DCl5InXY0gFyswjNLt+6vOxtPT+mOsrHkOuIg2PX6ZHSUemdDja/375Tlcti0DBiU3 BtAo/j6veIdfKXoXcBvwcVMEL8XFWtMhkOEvUYEnTU3GB0l2SGlc1A56iel7jyfONE6i FMcdyOJC9JsIFKDHfZomeP5cdnqK1DVy2XbAkMu7rgw2WC2phY6J6lzRi2f67lO6oZwl uU2smJVBZD2yBqRfML5jMu0rxz9vheAvK1bNclun8eKBzvOdqFjwnpsHSq6QJIlapUtF HzHuUU5Tdy3IU45lOfbLL7iQLheMr3PM5yJXDGJRNWns5cKkWaKcT/qjLTOi2bfmNXEO 2mZg== X-Received: by 10.194.9.33 with SMTP id w1mr25707288wja.103.1445935322824; Tue, 27 Oct 2015 01:42:02 -0700 (PDT) Original-Received: from firefly (dyn069045.nbw.tue.nl. [131.155.69.45]) by smtp.gmail.com with ESMTPSA id n17sm2553563wmg.17.2015.10.27.01.42.01 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 27 Oct 2015 01:42:01 -0700 (PDT) In-Reply-To: <87fv0xd2jr.fsf@web.de> (Michael Heerdegen's message of "Mon, 26 Oct 2015 17:20:40 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::236 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:192713 Archived-At: Michael Heerdegen writes: > Oleh Krehel writes: > >> The reason I dislike `pcase' is not because I don't know how to use it >> (the basic rules are actually pretty simple), it's because I think it >> leads to code that's hard to understand, maintain and transform. I >> dislike the trivial `if-let' and `when-let' for the same reasons. > > I like them because I think they make code easier to understand and > maintain. We can agree to disagree on this point. If I get an option to step into a `pcase', I'll be able to work with it just as well as with `cond'. I'll still never use it, but that's not the point. The point is that I have to interact with `pcase' code if I want to edit the Emacs core. >> I generally dislike any custom macro that includes `if' or binds >> variables. This is because I can't reason about the code that uses these >> macros unless I know exactly what they do in terms of binding variables >> and selecting branches. These macros don't follow the substitution model >> for procedure application (SMPA) [1], which is a valuable debugging >> technique for me. > > I wonder how you debug. With the built in debugger, with edebug, > something else? Knowing that would help understanding you problem. I debug with lispy [1], my package for Elisp and stuff. It's just a sophisticated "C-x C-e" - all the program stack is in the global variables. If you'd like to try it, simply press "p" on consecutive sexps to debug, e.g. "pjpjp". You can set up an initial stack with `edebug': just "xe" on a function, evaluate something that calls it to trigger `edebug' and press "Z". >> Maybe someone could explain the above, and also suggest the best way the >> create variable bindings from a pcase branch. > > `macroexpand' is your only choice if you want to have semantically > equivalent code you can actually run. `macroexpand' is the equivalent of stepping into a function call, when you want to just call the function instead and examine the return result. That's exactly my point about SMPA: you can only eval-and-replace this whole huge `pcase' construct at once, you can't decompose and evaluate it by parts. This should be done better. > If arbitrary `pcase' forms could be expanded to simpler code, well, we > should rewrite `pcase' to expand to this simpler code. I'd prefer "we should use the simpler code", but your suggestion is a step in the right direction as well :) thanks, Oleh [1]: https://github.com/abo-abo/lispy