Deutsch   English   Français   Italiano  
<vtn55a$17107$1@dont-email.me>

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

Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: James Kuyper <jameskuyper@alumni.caltech.edu>
Newsgroups: comp.lang.c
Subject: Re: Loops (was Re: do { quit; } else { })
Date: Tue, 15 Apr 2025 22:37:30 -0400
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <vtn55a$17107$1@dont-email.me>
References: <vspbjh$8dvd$1@dont-email.me> <vtc7mp$2q5hr$1@dont-email.me>
 <vtcqf6$3j95s$1@dont-email.me> <vtdh4q$b3kt$1@dont-email.me>
 <vtf7fe$1qtpg$1@dont-email.me> <vtgfuf$31ug1$1@dont-email.me>
 <20250413072027.219@kylheku.com> <vtgpce$39229$1@dont-email.me>
 <vti2ki$g23v$1@dont-email.me> <vtin99$vu24$1@dont-email.me>
 <vtiuf0$18au8$1@dont-email.me> <vtj97r$1i3v3$1@dont-email.me>
 <vtl166$36p6b$1@dont-email.me> <vtlcg0$3f46a$2@dont-email.me>
 <20250415053852.166@kylheku.com> <vtm4ae$6d5j$1@dont-email.me>
 <H7yLP.2056536$OrR5.1414451@fx18.iad> <vtmgj8$g81k$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 16 Apr 2025 04:37:51 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="c987168a027414eea408640e9a1bdb09";
	logging-data="1278983"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+b3FrdXHM+Jug3F1lSuxok2m9PGReNuFk="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:BdddeRSBlMAoWdigQg3jTvHqL30=
Content-Language: en-US
In-Reply-To: <vtmgj8$g81k$1@dont-email.me>

On 2025-04-15, bart <bc@freeuk.com> wrote:
> Note that C's for-loop is dumb; it merely take three expressions A B C 
> that can be completely unrelated, and arranges them into a loop:
>
>    A; while (B) {...; C}
Note that this problem is not unique to the for() statement. An
assignment statement allows you to arrange three unrelated expressions
together like

A = B + C;

"Doctor, it hurts when I hit my head with a hammer!"
"Then stop doing that."

The key to using the for() statement is to make sure the three
expressions are related appropriately. Many different powerful and
useful ways of using a for() statement have been shown in this thread
that are not equivalent to for(int i=start; i<end; i += increment).
Individually, those uses aren't particularly common, but collectively
I've needed each of those uses often enough to be grateful that C has
such a flexible construct to do it with.