Sujet : Re: C23 thoughts and opinions
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 02. Jun 2024, 20:52:22
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240602124448.704@kylheku.com>
References : 1 2 3 4 5 6
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2024-06-02, Lew Pitcher <
lew.pitcher@digitalfreehold.ca> wrote:
I've always considered
for (;;)
preferable over
while (1)
Of course it is preferable. The idiom constitutes the language's direct
support for unconditional looping, not requiring that to be requested by
an extraneous always-true expression.
Using while (1) or while (true) is like i = i + 1 instead
of ++i, or while (*dst++ = *src++); instead of strcpy.
When Dennis Ritchie (if it was indeed he) chose for to be the construct
in which the guard expression may be omitted, so that it may express
conditional looping, he expressed the intent that it be henceforth used
for that purpose.
To continue to use while (1) after the proper utensil is provided is
like to eat with your hands instead of a fork.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca