Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: Sort of trivial code challenge - may be interesting to you anyway
Date: Wed, 11 Mar 2026 06:33:56 -0700
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <86cy1aa3sr.fsf@linuxsc.com>
References: <10n80sc$3soe4$1@dont-email.me> <86v7feei2e.fsf@linuxsc.com> <10o53k6$1i0ef$2@dont-email.me> <86ms0peby6.fsf@linuxsc.com> <10ockdh$3qpk6$1@dont-email.me> <10ocrjn$3qpk6$2@dont-email.me> <10od64s$3qpk6$4@dont-email.me> <86ikb9bmtw.fsf@linuxsc.com> <10oem5t$n5hk$1@dont-email.me> <86o6kz9zng.fsf@linuxsc.com> <10oi72k$1rss6$1@dont-email.me> <10oid0u$1u9aa$2@dont-email.me> <10ok1sl$2e7mc$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Wed, 11 Mar 2026 13:34:00 +0000 (UTC)
Injection-Info: dont-email.me; posting-host="5f44bcdbc02769ce6998caa4a4cb2206"; logging-data="1172321"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/a1ujH5d+RN6pjMZBit00GtNL6br7efcY="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:BouH3/yQCB2Jz4IgmZwECc9Ciqg= sha1:dOu08HTx6r4PsDxozyJdnnhpNbQ=
Xref: csiph.com comp.lang.c:396901
DFS writes:
[...]
> Nested ternaries like this:
>
> c = square ? a1 : !hwc ? h*w : a3 > h*w ? h*w : a3;
>
> are harder to decipher at first glance than 3 or 4 levels of
> indented if-then-elses.
Again that is only because you aren't used to them. Note by the
way that the conditional expression is not nested, any more than
a chain of if-elseif-elseif-else is nested
if(x){
...
} else if(y){
...
} else if(z){
...
} else {
...
}
Of course syntactically this construct is nested, but normally
how people think of it is not as being nested.