Liste des Groupes | Revenir à cl c |
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.
Les messages affichés proviennent d'usenet.