Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Rosario19 Newsgroups: comp.lang.c Subject: Re: Loops (was Re: do { quit; } else { }) Date: Wed, 16 Apr 2025 12:09:10 +0200 Organization: A noiseless patient Spider Lines: 27 Message-ID: <670vvjht4glvq04f9dv7c4nqlffbh6a292@4ax.com> References: <20250413072027.219@kylheku.com> <20250415152550.00007634@yahoo.com> <20250415062839.904@kylheku.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Date: Wed, 16 Apr 2025 12:09:11 +0200 (CEST) Injection-Info: dont-email.me; posting-host="431cd07a010af455f22b1e37a7d2e176"; logging-data="2067494"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+YZCrisev2qza9+l5gEOZ7CgygDrQ10cc=" Cancel-Lock: sha1:A8X166I2vVBjrEG7hpol7sSDhT0= X-Newsreader: Forte Free Agent 1.93/32.576 English (American) On Tue, 15 Apr 2025 13:33:21 -0000 (UTC), Kaz Kylheku wrote: >On 2025-04-15, bart wrote: >> * Not having to write the variable 3 times (with C not always being >> able to detect if they didn't match) > >This is indeed a source of errors in C nested loops. Say we have >these macros: > > FOR (i, 0, N-1) > FOR (j, 0, i) > ... > >we are less likely to make some copy paste error like >=20 > for (i =3D 0; i < N; i++) > for (j =3D 0; j < i; i++) > ... > >Int he past, I've run into bugs in nested loops, along these lines. if F is a macro as #define F for until now i not find any inconvenient for me at last >In loop-heavy code, making a macro like the FOR above might not >be a bad idea.