all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: "Przemysław Wojnowski" <esperanto@cumego.com>
Cc: Emacs Development <emacs-devel@gnu.org>
Subject: Re: Question on pcase
Date: Fri, 23 Oct 2015 23:01:46 +0200	[thread overview]
Message-ID: <877fmd5mf9.fsf@web.de> (raw)
In-Reply-To: <562A91AA.3030208@cumego.com> ("Przemysław Wojnowski"'s message of "Fri, 23 Oct 2015 21:59:38 +0200")

Przemysław Wojnowski <esperanto@cumego.com> 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" part:
> (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.



  reply	other threads:[~2015-10-23 21:01 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 [this message]
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
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=877fmd5mf9.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=emacs-devel@gnu.org \
    --cc=esperanto@cumego.com \
    /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.