[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: combining cond and let, to replace pcase.
From: |
Richard Stallman |
Subject: |
Re: combining cond and let, to replace pcase. |
Date: |
Sat, 25 Nov 2023 22:14:44 -0500 |
[[[ To any NSA and FBI agents reading my email: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
> Only gut feelings here, but fall thru with bindings by default and
> multiple t may surprise users and lead to not simple to debug code.
It would be a trivial change to replace t with some keyword, for that
functionality. Would it actually be better? What do other s think?
Here's a more uniform version, in which each clause
exits if it contains more than one element (after the possible keyword),
and falls through otherwise. This makes it unnecessary to redefine
what t means as a condition -- that can be written another way (see below).
(cond*
;; Same as a clause in `cond',
(CONDITION
DO-THIS-IF-TRUE-THEN-EXIT...)
;; Execute FORM and ignore its value.
(FORM)
;; Variables to bind, as in let
(:bind ((x foobar) y z (foo 5) a))
;; Bindings continue in effect.
;; Extracts substructure and binds variables around the rest
;; of the cond*.
(:match (`(expt ,foo ,bar) x)
DO-THIS-IF-IT-MATCHED-THEN-EXIT...)
;; Bindings continue in effect.
;; Like above but always falls thru to next clause.
(:match (`(expt ,foo ,bar) x))
;; Bindings continue in effect.
)
To execute several expressions and not exit, use this:
((progn DO-THIS-UNCONDITIONALLY-AND-DONT-STOP...)
--
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)
- Re: combining cond and let, to replace pcase., (continued)
- Re: combining cond and let, to replace pcase., Michael Heerdegen, 2023/11/21
- Re: combining cond and let, to replace pcase., Axel Forsman, 2023/11/19
- Re: combining cond and let, to replace pcase., Michael Heerdegen, 2023/11/21
- Re: combining cond and let, to replace pcase., Richard Stallman, 2023/11/22
- Re: combining cond and let, to replace pcase., Tomas Hlavaty, 2023/11/23
- Re: combining cond and let, to replace pcase., Richard Stallman, 2023/11/25
- Re: combining cond and let, to replace pcase., Tomas Hlavaty, 2023/11/27
- Re: combining cond and let, to replace pcase., Yuri Khan, 2023/11/27
- Re: combining cond and let, to replace pcase., Tomas Hlavaty, 2023/11/28
- Re: combining cond and let, to replace pcase., Manuel Giraud, 2023/11/23
- Re: combining cond and let, to replace pcase.,
Richard Stallman <=
- Re: combining cond and let, to replace pcase., Daniel Semyonov, 2023/11/23
- Re: combining cond and let, to replace pcase., Daniel Semyonov, 2023/11/23
- Re: combining cond and let, to replace pcase., Richard Stallman, 2023/11/24
- Re: combining cond and let, to replace pcase., Stefan Monnier, 2023/11/25
- Re: combining cond and let, to replace pcase., Richard Stallman, 2023/11/26
- Re: combining cond and let, to replace pcase., Richard Stallman, 2023/11/26
- Re: combining cond and let, to replace pcase., Manuel Giraud, 2023/11/27
- Re: combining cond and let, to replace pcase., Yuri Khan, 2023/11/27
- Re: combining cond and let, to replace pcase., Stefan Monnier, 2023/11/27
- Re: combining cond and let, to replace pcase., Richard Stallman, 2023/11/28