[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: The poor state of documentation of pcase like things.
From: |
Michael Heerdegen |
Subject: |
Re: The poor state of documentation of pcase like things. |
Date: |
Sun, 03 Jan 2016 02:32:58 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
Lars Magne Ingebrigtsen <address@hidden> writes:
> 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.
That code indeed looks weird. But you can also write similarly weird
code with `cond'.
> 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.
The concept (one can combine different types of things and tests -
destructuring, predicate testing, matching against constants etc.) has
it's pros and cons. In cases where one single tool doesn't fit, it is a
very good thing when the code doesn't need to nest different types of
tools, and the layout can concentrate on the different cases.
Michael.
- Re: The poor state of documentation of pcase like things., (continued)
- 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, 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., 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 <=
- 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
- Message not available
- Message not available
- Message not available
- Message not available
- Message not available
- Message not available
- Message not available
- Message not available
- Message not available
- 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., Dmitry Gutov, 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., Dmitry Gutov, 2016/01/03