all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Oleh Krehel <ohwoeowho@gmail.com>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: Eli Zaretskii <eliz@gnu.org>, Emacs Development <emacs-devel@gnu.org>
Subject: Re: Question on pcase
Date: Tue, 27 Oct 2015 09:42:33 +0100	[thread overview]
Message-ID: <87egggya6e.fsf@gmail.com> (raw)
In-Reply-To: <87fv0xd2jr.fsf@web.de> (Michael Heerdegen's message of "Mon, 26 Oct 2015 17:20:40 +0100")

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Oleh Krehel <ohwoeowho@gmail.com> 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



  reply	other threads:[~2015-10-27  8:42 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-22 14:46 Question on pcase Oleh Krehel
2015-10-22 21:19 ` Michael Heerdegen
2015-10-23  6:30   ` Eli Zaretskii
2015-10-23 11:58     ` Oleh Krehel
2015-10-23 12:23       ` Michael Heerdegen
2015-10-23 12:42         ` Oleh Krehel
2015-10-23 13:07           ` Michael Heerdegen
2015-10-23 13:26             ` Oleh Krehel
2015-10-23 13:59               ` Michael Heerdegen
2015-10-27 23:50                 ` Johan Bockgård
2015-10-30  1:33                   ` Michael Heerdegen
2015-10-23 14:23               ` Michael Heerdegen
2015-10-23 12:17     ` Michael Heerdegen
2015-10-23 12:22       ` Oleh Krehel
2015-10-23 13:26       ` Eli Zaretskii
2015-10-23 14:14         ` Michael Heerdegen
2015-10-23 14:41           ` Eli Zaretskii
2015-10-23 18:38             ` Michael Heerdegen
2015-10-23 18:43               ` Eli Zaretskii
2015-10-23 19:59               ` Przemysław Wojnowski
2015-10-23 21:01                 ` Michael Heerdegen
2015-10-23 20:23               ` Przemysław Wojnowski
2015-10-23 20:39                 ` Michael Heerdegen
2015-10-24 11:37                   ` Przemysław Wojnowski
2015-10-24  9:01               ` Alan Mackenzie
2015-10-24 12:58                 ` Stephen Berman
2015-10-24 17:47                   ` Alan Mackenzie
2015-10-24 19:10                     ` Stephen Berman
2015-10-24 19:28                       ` Alan Mackenzie
2015-10-25  0:00                         ` pcase docstring tweaks (was: Question on pcase) Michael Heerdegen
2015-10-27 14:54                           ` pcase docstring tweaks Michael Heerdegen
2015-10-27 18:57                             ` Stefan Monnier
2015-10-27 20:14                               ` Michael Heerdegen
2015-10-28  3:15                             ` Richard Stallman
2015-10-28 17:08                               ` Michael Heerdegen
2015-10-24 17:00                 ` Question on pcase Drew Adams
2015-10-24 17:22                   ` Alan Mackenzie
2015-10-24 17:36                     ` Drew Adams
2015-10-24 20:03                     ` Johan Bockgård
2015-10-24 23:11                       ` Michael Heerdegen
2015-10-26 15:55               ` Oleh Krehel
2015-10-26 16:07                 ` Michael Heerdegen
2015-10-27  8:42                   ` Oleh Krehel
2015-10-26 16:20                 ` Michael Heerdegen
2015-10-27  8:42                   ` Oleh Krehel [this message]
2015-10-27 14:27                     ` Michael Heerdegen
2015-10-27 14:47                       ` Michael Heerdegen
2015-10-28 18:05                         ` Michael Heerdegen
2015-10-29  9:44                           ` Oleh Krehel
2015-10-30  1:11                             ` Michael Heerdegen
2015-10-26 16:35                 ` Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87egggya6e.fsf@gmail.com \
    --to=ohwoeowho@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=michael_heerdegen@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.