[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Instead of pcase
From: |
Stefan Monnier |
Subject: |
Re: Instead of pcase |
Date: |
Fri, 24 Nov 2023 23:34:24 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
> (let ((exp (if t '(foo . "str") '(bar . 7))))
> (cl-case (car exp)
> (foo
> (when-let ((d (cdr exp)))
> (concat "str" val)))
> (bar
> (when-let ((d (cdr exp)))
> (1+ val)))))
AKA
(let ((exp (if t '(foo . "str") '(bar . 7))))
(case (car exp)
('foo
(when-let ((d (cdr exp)))
(concat "str" val)))
('bar
(when-let ((d (cdr exp)))
(1+ val)))))
Funnily enough this quoting of the values against which we want to match
is so natural for coders not familiar with `cl-case` that we went
through some efforts to try and detect their mis-use.
So at least for some coders, in the above case, the `pcase` syntax is the
more natural one :-)
Stefan
- Re: Instead of pcase, (continued)
- Re: Instead of pcase, Spencer Baugh, 2023/11/16
- Re: Instead of pcase, Tomas Hlavaty, 2023/11/16
- combining cond and let, to replace pcase., Richard Stallman, 2023/11/17
- Re: combining cond and let, to replace pcase., Michael Heerdegen, 2023/11/19
- Re: combining cond and let, to replace pcase., Eli Zaretskii, 2023/11/19
- Re: combining cond and let, to replace pcase., Gerd Möllmann, 2023/11/19
- Re: combining cond and let, to replace pcase., Eli Zaretskii, 2023/11/19
- Re: combining cond and let, to replace pcase., Gerd Möllmann, 2023/11/19
- Re: combining cond and let, to replace pcase., Eli Zaretskii, 2023/11/19
- Re: combining cond and let, to replace pcase., Gerd Möllmann, 2023/11/19
- Re: combining cond and let, to replace pcase., Eli Zaretskii, 2023/11/19