Re: C23 thoughts and opinions

Liste des GroupesRevenir à cl c 
Sujet : Re: C23 thoughts and opinions
De : bc (at) *nospam* freeuk.com (bart)
Groupes : comp.lang.c
Date : 03. Jun 2024, 23:43:00
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v3lgti$325i$1@dont-email.me>
References : 1 2 3 4 5 6 7
User-Agent : Mozilla Thunderbird
On 02/06/2024 20:52, Kaz Kylheku wrote:
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.
 
To me they're both an abomination.
I classify loops like this: Endless, Repeat-N-times, While, Iteration (over ranges or values).
Few languages have a special form for the first two, but mine always have done.
'while' is no good for endless loops because there is no actual condition to check. You have to provide one just for it to be eliminated.
'for' is even worse because there is no sort of iteration going on. Actually, somebody could write a loop like this:
    for(int i=0;;++i)
Is that an endless loop or not? Like every other for-loop, you have to analyse it to deduce the intent. Here, you can't even be sure that the empty condition wasn't an oversight.
At this point someone will suggest a macro this:
   #define forever for(;;)
All that suggest sto me is that the language *needs* an explicit endless loop!

Date Sujet#  Auteur
31 May 24 * Re: C23 thoughts and opinions20Lynn McGuire
1 Jun 24 +- Re: C23 thoughts and opinions1David Brown
2 Jun 24 `* Re: C23 thoughts and opinions18Lawrence D'Oliveiro
2 Jun 24  +- Re: C23 thoughts and opinions1Keith Thompson
2 Jun 24  `* Re: C23 thoughts and opinions16Kenny McCormack
2 Jun 24   `* Re: C23 thoughts and opinions15Lew Pitcher
2 Jun 24    +* Re: C23 thoughts and opinions13Kaz Kylheku
3 Jun 24    i+- Re: C23 thoughts and opinions1Michael S
3 Jun 24    i+* Re: C23 thoughts and opinions5Tim Rentsch
3 Jun 24    ii`* Re: C23 thoughts and opinions4Chris M. Thomasson
3 Jun 24    ii `* Re: C23 thoughts and opinions3Kenny McCormack
4 Jun 24    ii  `* Re: C23 thoughts and opinions2David Brown
4 Jun 24    ii   `- Re: C23 thoughts and opinions1Chris M. Thomasson
3 Jun 24    i`* Re: C23 thoughts and opinions6bart
4 Jun 24    i +* Re: C23 thoughts and opinions2Keith Thompson
4 Jun 24    i i`- Re: C23 thoughts and opinions1David Brown
4 Jun 24    i +* Re: C23 thoughts and opinions2Lawrence D'Oliveiro
4 Jun 24    i i`- Re: C23 thoughts and opinions1David Brown
4 Jun 24    i `- Re: C23 thoughts and opinions1Kaz Kylheku
3 Jun 24    `- Re: C23 thoughts and opinions1Tim Rentsch

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal