Re: C23 thoughts and opinions

Liste des GroupesRevenir à cl c 
Sujet : Re: C23 thoughts and opinions
De : david.brown (at) *nospam* hesbynett.no (David Brown)
Groupes : comp.lang.c
Date : 04. Jun 2024, 09:36:00
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v3mjlg$bpds$2@dont-email.me>
References : 1 2 3 4 5
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0
On 03/06/2024 23:48, Kenny McCormack wrote:
In article <v3lb0u$2452$1@dont-email.me>,
Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
On 6/3/2024 1:31 PM, Tim Rentsch wrote:
Kaz Kylheku <643-408-1753@kylheku.com> writes:
>
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.  [...]
>
Using for (;;) for an infinite loop is an abomination.  Anyone
who advocates following that rule is an instrument of Satan.
>
Better than goto? ;^D
 I can't believe we're still having this conversation.
 Surely, on any reasonably modern compiler, all three forms will generate
exactly the same code.
 
I would think so, yes.  (I've used toolchains where that was not true, but they are firmly in my past.)
But conversations - arguments - about style of source code /never/ get out of date!
Personally, I'm in the "while (true) { ... }" camp.  To me, "for (;;)" looks like a weird smiley, and I do not fall for any appeals to Deniis Ritchie's authority.
But we are missing another option:
void mainloop() {
// do something
mainloop();
}
That should be fine with an optimising compiler.

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