[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: The poor state of documentation of pcase like things.
From: |
Drew Adams |
Subject: |
RE: The poor state of documentation of pcase like things. |
Date: |
Fri, 1 Jan 2016 19:51:39 -0800 (PST) |
> > (pcase skip
> > (`nil nil)
> > (`0 t)
> > (_ (setq i (+ i skip -1)) (funcall get-next-frame)))
>
> (cond ((null skip))
> ((eq skip 0) t)
> (t (setq i (+ i skip -1))
> (funcall get-next-frame)))
Agreed. If you don't need decomposition by pattern matching,
why would you need `pcase'?
(But as pointed out, the first clause should be ((null skip) nil).
(The `cond' is 10 chars more to type in this case, not counting
insignificant whitespace. But that is not important.)
Or:
(cl-case skip
((nil) nil)
(0 t)
(t (setq i (+ i skip -1)) (funcall get-next-frame)))
(Same number of chars as `pcase'. Or 3 fewer, if you use alias\
`case'. But, again, not important.)
Or:
(and skip (or (eql 0 skip)
(progn (setq i (+ i skip -1))
(funcall get-next-frame))))
(3 chars more than the `pcase'. But not important.)
> Not much difference. Also, `0 could just be 0.
>
> One thing it does do: avoids repeating "skip" in the first two tests. That's
> the only merit I can see, but would have been more worthwhile if there were,
> say, 10 value tests.
The same is true of `cl-case' (it is one of the reasons for
that macro). But otherwise, just use `let':
(let ((sk skip))
(and sk (or (eql 0 sk)
(progn (setq i (+ i skip -1))
(funcall get-next-frame))))
- 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., 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., Michael Heerdegen, 2016/01/03
- RE: The poor state of documentation of pcase like things., Drew Adams, 2016/01/04
- 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., Eli Zaretskii, 2016/01/04
- 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., Richard Copley, 2016/01/01
- RE: The poor state of documentation of pcase like things., Drew Adams, 2016/01/01
RE: The poor state of documentation of pcase like things.,
Drew Adams <=