Sujet : Re: else ladders practice
De : bc (at) *nospam* freeuk.com (Bart)
Groupes : comp.lang.cDate : 04. Nov 2024, 13:38:06
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vgaf7e$ui7l$1@dont-email.me>
References : 1 2 3 4 5 6 7 8
User-Agent : Mozilla Thunderbird
On 04/11/2024 12:29, Janis Papanagnou wrote:
On 04.11.2024 12:56, Bart wrote:
[...]
>
Here, the question was, can:
>
if (c1) s1;
else if (c2) s2;
>
always be rewritten as:
>
if (c1) s1;
if (c2) s2;
Erm, no. The question was even more specific.
I mean that the question came down to this. After all he had already decided on that second form rather than the first, and had acknowledged that the 'else's were missing.
That the OP's example contained some clear patterns has already been covered (I did so anyway).
It had (per example)
not only all ci disjunct but also defined as a linear sequence of
natural numbers! - In other languages [than "C"] this may be more
important since [historically] there were specific constructs for
that case; see e.g. 'switch' definitions in Simula, or the 'case'
statement of Algol 68, both mapping elements onto an array[1..N];
labels in the first case, and expressions in the latter case. So
in "C" we could at least consider using something similar, like,
say, arrays of function pointers indexed by those 'n'.
That too!
! (Not that
I'd suggest that by just pointing it out.)
I'm a bit astonished, BTW, about this huge emphasis on the topic
"opinions" in later posts of this thread. The OP asked (even in
the subject) about "practice" which actually invites if not asks
for providing opinions (besides practical experiences).