Sujet : Re: Loops (was Re: do { quit; } else { })
De : Ros (at) *nospam* invalid.invalid (Rosario19)
Groupes : comp.lang.cDate : 16. Apr 2025, 11:09:10
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <670vvjht4glvq04f9dv7c4nqlffbh6a292@4ax.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14
User-Agent : 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
for (i = 0; i < N; i++)
for (j = 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.