Deutsch   English   Français   Italiano  
<vu3ve9$21pgn$1@news.xmission.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.snarked.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.c
Subject: Re: Loops (was Re: do { quit; } else { })
Date: Sun, 20 Apr 2025 23:19:37 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <vu3ve9$21pgn$1@news.xmission.com>
References: <vspbjh$8dvd$1@dont-email.me> <vu2hmg$3jn88$1@dont-email.me> <vu2mkc$3noft$1@dont-email.me> <87ldruv65j.fsf@nosuchdomain.example.com>
Injection-Date: Sun, 20 Apr 2025 23:19:37 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
	logging-data="2156055"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
Bytes: 2053
Lines: 31

In article <87ldruv65j.fsf@nosuchdomain.example.com>,
Keith Thompson  <Keith.S.Thompson+u@gmail.com> wrote:
....
>I understand and completely accept that you find the while loop
>clearer, and I have no interest in changing your mind.
>
>I find the for loop clearer.  I won't speak for anyone else, but I
>suspect a lot of C programmers would also find the for loop clearer.

I'm with Bart on this one.  I think "for" loops that aren't simple
iterations (i.e., do this thing 10 times), are harder to understand than
the equivalent "while" loop.  I.e., this:

    p = someComplexFunctionCall(this,that,the,other,thing);
    while (p) {
	do stuff;
	p = getNewValue(p);
	}

is a lot easier to understand at first glance than the equivalent:

    for (p = someComplexFunctionCall(this,that,the,other,thing); p; p = getNewValue(p))
	do stuff;

But, having said that, I'll always write the "for" version, because I like
writing compact (some would say "cryptic") code.  Job security, and all that...

-- 
Meatball Ron wants to replace the phrase "climate change" with the phrase
"energy dominance" in policy discussions.

Yeah, like that makes a lot of sense...