[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: |
Mon, 08 Jan 2024 15:42:00 +0000 |
Richard Stallman <rms@gnu.org> writes:
> > > 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
>
> Perhaps we are miscommunicating.
>
> `or' and `and' can act as conditionals. (and X Y) says to
> do Y if X is true. (or X Y) says to do Y if X is false.
> That is why those constructs are useful.
IMHO, it is a better practice to do code flow control via special forms
like `if', `when', `prog1', `progn', etc.
In my mind, `or' and `and' are to be used as function (they are, indeed,
functions). Treating them as flow control constructs may lead to
confusion, as it did for you.
> `xor' can'e be used as a conditional, because all of the arguments of
> `xor' must always be evaluatedd.
`xor' is a function - in cond*, PRED may be any function. And the fact
that not all the arguments are evaluated in (PRED x arg1 arg2 ...) is
the source of my confusion and the reason why I objected the idea of
PRED in its current form when "x" not visually distinct from the rest of
the arguments.
--
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>