Sujet : Re: Loops (was Re: do { quit; } else { })
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 15. Apr 2025, 14:33:21
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20250415062839.904@kylheku.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2025-04-15, bart <
bc@freeuk.com> 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.
In loop-heavy code, making a macro like the FOR above might not
be a bad idea.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca