Sujet : Re: Command Languages Versus Programming Languages
De : sebastian (at) *nospam* here.com.invalid (Sebastian)
Groupes : comp.unix.shell comp.unix.programmer comp.lang.miscDate : 25. Aug 2024, 09:32:26
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vaemm8$1q5l3$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13
User-Agent : tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.1.0-18-amd64 (x86_64))
In comp.unix.programmer Lawrence D'Oliveiro <
ldo@nz.invalid> wrote:
On Tue, 6 Aug 2024 08:04:35 -0000 (UTC), Sebastian wrote:
Better:
a = b ? (c ? d : e) :
f ? (g ? h : i) :
j;
Better still (fewer confusing parentheses):
a =
b ?
c ? d : e
: f ?
g ? h : i
: j;
I find this more confusing than the parentheses.
Equivalent Lisp, for comparison:
(setf a (cond (b (if c d e))
(f (if g h i))
(t j)))
You can?t avoid the parentheses, but this, too, can be improved:
(setf a
(cond
(b
(if c d e)
)
(f
(if g h i)
)
(t
j
)
) ; cond
)
If you insist on writing Lisp like that, you might as well do
this:
(ql:quickload :with-c-syntax)
(named-readtables:in-readtable with-c-syntax:with-c-syntax-readtable)
#{
a = b ? (c ? d : e) :
f ? (g ? h : i) :
j;
#}