[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: The poor state of documentation of pcase like things.
From: |
Lars Magne Ingebrigtsen |
Subject: |
Re: The poor state of documentation of pcase like things. |
Date: |
Sun, 03 Jan 2016 02:07:57 +0100 |
User-agent: |
Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.1.50 (gnu/linux) |
Dmitry Gutov <address@hidden> writes:
> On 01/02/2016 10:16 AM, Eli Zaretskii wrote:
>
>> Now that I know there isn't, I can convert such code to using 'cond'
>> whenever I feel like it. Like we do with whitespace changes.
>
> FWIW, converting that kind of pcase form to a cond, to my eyes, would
> look like replacing (when ...) with (if ... (progn ...))).
Well, I'd say that pcase is kinda awkward because you can't tell by
skimming whether it's complex or not (which is something it shares with
cond, in a way). Take for instance the following I was reading in
url-http (simplified and way shortened):
(pcase status-symbol
(`unauthorized ; 401
(url-http-handle-authentication nil))
(`payment-required ; 402
(url-mark-buffer-as-dead buffer)
(error "Somebody wants you to give them money"))
(`forbidden ; 403
t)
(`not-found ; 404
t)
(`method-not-allowed ; 405
t)
...)
The only way you'll know whether `status-symbol' is really a symbol, and
all the cases are really symbols, is by reading the entire thing. The
44th case could have been (_ foo bar zot), for instance.
In Common Lisp, you'd say
(case status-symbol
(unauthorized ; 401
(url-http-handle-authentication nil))
(payment-required ; 402
(url-mark-buffer-as-dead buffer)
(error "Somebody wants you to give them money"))
(forbidden ; 403
t)
(not-found ; 404
t)
(method-not-allowed ; 405
t)
...)
and you'd know that this was a simple `eql' thing going on here.
I kinda liked pcase at first, but the more I see of the pcase language,
the more sceptical I get. I'm beginning to wonder whether the whole
thing is a misfeature that should be replaced with several separate
operators.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
- Re: The poor state of documentation of pcase like things., (continued)
- Re: The poor state of documentation of pcase like things., Eli Zaretskii, 2016/01/03
- Re: The poor state of documentation of pcase like things., Michael Heerdegen, 2016/01/03
- Re: The poor state of documentation of pcase like things., David Kastrup, 2016/01/03
- Re: The poor state of documentation of pcase like things., Michael Heerdegen, 2016/01/03
- Re: The poor state of documentation of pcase like things., John Wiegley, 2016/01/04
- Re: The poor state of documentation of pcase like things., Dmitry Gutov, 2016/01/02
- Re: The poor state of documentation of pcase like things.,
Lars Magne Ingebrigtsen <=
- Re: The poor state of documentation of pcase like things., Dmitry Gutov, 2016/01/02
- RE: The poor state of documentation of pcase like things., Drew Adams, 2016/01/02
- Re: The poor state of documentation of pcase like things., David Kastrup, 2016/01/03
- Re: The poor state of documentation of pcase like things., Michael Heerdegen, 2016/01/02
- RE: The poor state of documentation of pcase like things., Drew Adams, 2016/01/02
- Re: The poor state of documentation of pcase like things., Noam Postavsky, 2016/01/02
- Re: The poor state of documentation of pcase like things., Dmitry Gutov, 2016/01/02
- Re: The poor state of documentation of pcase like things., John Wiegley, 2016/01/02
- RE: The poor state of documentation of pcase like things., Drew Adams, 2016/01/02
- Re: The poor state of documentation of pcase like things., Eli Zaretskii, 2016/01/02