[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Instead of pcase
|
From: |
Ihor Radchenko |
|
Subject: |
Re: Instead of pcase |
|
Date: |
Sat, 06 Jan 2024 13:04:44 +0000 |
Richard Stallman <rms@gnu.org> writes:
> > Consider another example:
>
> > (match* (xor (not var) t) t)
>
> Anyway, I suppose the best response is to say that such counterintuitive
> constrained variables are best avoided. Or else specifically disallow
> `xor' as PRED in a constrained variable.
My point is not about `xor' in particular.
What I am trying to demonstrate is that
(foo (bar var) arg) looks like a normal Elisp call - `foo' called with
two arguments: (bar var) and arg.
Yet, it has completely different meaning inside match*.
So, it is very easy to confuse match* clause result with return value of
the equivalent normal Elisp expression.
In contrast, a more explicit
(match* (constrain var (and (bar var) (foo var arg))) ...)
(match* (constrain var (and (not var) (xor var t)) t) ...)
is much more natural and avoids confusion.
> ...
> I wonder why people defined `xor'. It can't be used
> as a conditional, like `and' and `or', so what is the point of it?
`xor' can be used as conditional, and it also comes handy at time (we
have 7 functions using `xor' in Org mode, for example).
But that's off-topic to `pcase' discussion.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>