[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question on pcase
From: |
Przemysław Wojnowski |
Subject: |
Re: Question on pcase |
Date: |
Fri, 23 Oct 2015 21:59:38 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
W dniu 23.10.2015 o 20:38, Michael Heerdegen pisze:
I wrote a step by step introduction for people who (1) are frightened by
`pcase' and (2) are willing to invest some (not much, but some) time to
learn it. It is how I would describe `pcase' to a friend, maybe it is
good for learning, maybe it is ugly, dunno. Some errors included.
Someone who wants to try to learn pcase (Oleh? Oleh!) can help by
reading it and telling me if it is understandable, and send corrections
- or write a better introduction ;-) - and format it nicely for
inclusion into Elpa or Emacs when it turns out to help people.
Thanks for the tutorial! :-)
I didn't know what pcase is until I read the first few lines. Then I
just realized that it's just a version of Pattern Matching that I know
from Clojure (https://youtu.be/mi3OtBc73-k - is a good intro).
Anyway, I read the tutorial and IMHO it is mostly clear. I just have a
few questions and comments:
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?
---------------
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.
---------------
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.
---------------
What are some good (concrete) use cases for the pcase? When would you
suggest to use it instead of cond or other similar constructs?
---------------
Great job!
Thanks,
Przemysław
- Re: Question on pcase, (continued)
- Re: Question on pcase, Michael Heerdegen, 2015/10/23
- Re: Question on pcase, Oleh Krehel, 2015/10/23
- Re: Question on pcase, Eli Zaretskii, 2015/10/23
- Re: Question on pcase, Michael Heerdegen, 2015/10/23
- Re: Question on pcase, Eli Zaretskii, 2015/10/23
- Re: Question on pcase, Michael Heerdegen, 2015/10/23
- Re: Question on pcase, Eli Zaretskii, 2015/10/23
- Re: Question on pcase,
Przemysław Wojnowski <=
- Re: Question on pcase, Michael Heerdegen, 2015/10/23
- Re: Question on pcase, Przemysław Wojnowski, 2015/10/23
- Re: Question on pcase, Michael Heerdegen, 2015/10/23
- Re: Question on pcase, Przemysław Wojnowski, 2015/10/24
- Re: Question on pcase, Alan Mackenzie, 2015/10/24
- Re: Question on pcase, Stephen Berman, 2015/10/24
- Re: Question on pcase, Alan Mackenzie, 2015/10/24
- Re: Question on pcase, Stephen Berman, 2015/10/24
- Re: Question on pcase, Alan Mackenzie, 2015/10/24
- pcase docstring tweaks (was: Question on pcase), Michael Heerdegen, 2015/10/24