Liste des Groupes | Revenir à cl c |
On Sun, 04 May 2025 07:31:11 -0700^^^^^^^^^
Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
Michael S <already5chosen@yahoo.com> writes:
On Tue, 15 Apr 2025 11:30:24 +0100
bart <bc@freeuk.com> wrote:
Let me ask you this: what exactly is the point of the 'while'>
statement in C? Since it can always be trivially be written as:
>
for (;cond;)
>
It seems to that most use cases (initialise, check exit
condition, change something that affects the letter), would suit
'for' better.
>
But since 'for' then becomes overloaded, there ought to be a
dedicated feature for simple iteration. So it seems the solution
is as a I suggested above.
I suspect that 'while' loop is here in C because Dennis Ritchie
wanted 'do .. while() ' and thought that if the keyword is here
anyway than why not reuse it?
According to K&R, all of the basic control structures in C -- if,
while, for, do, and switch (and listed in that order) -- were
provided in BCPL, though not using the same syntax as in C,.
In the hindsight, probably a mistake.
I admit I don't understand this reaction.
I don't like reuse of keyboards. Neither of 'while' nor of 'break' nor
of 'static' (even more so in C++) nor use of 'long' modifier both for^^
integer and for floating-point types.
Double meaning of 'while' adds unnecessary mental load for a code
reader. Not a lot of it, but still unnecessary.
Also having just one form of loop with pre-condition strikes me as
more elegant. Since elegance is strongly subjective, I have no logical
arguments in support of me feelings.
Les messages affichés proviennent d'usenet.