Sujet : Re: Loops (was Re: do { quit; } else { })
De : bc (at) *nospam* freeuk.com (bart)
Groupes : comp.lang.cDate : 16. Apr 2025, 16:14:03
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vtohfp$2db8v$3@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
User-Agent : Mozilla Thunderbird
On 16/04/2025 15:47, James Kuyper wrote:
bart <bc@freeuk.com> writes:
On 16/04/2025 06:35, Janis Papanagnou wrote:
>
So here, 0% of such loops have a step other than 1. THAT's what I mean
by 'unusual'.
The files easily accessible to me contain 13965 for statements, of which
596 used a step other than 1.
(I assume you mean other than +1 or -1.)
So about 4%. What tool did you use to determine that?
If I look at sql.c (which includes sqlite3.c), there are 1900 for-statements.
Among those, 40 involve += or -=, usually in the increment part, however I didn't look too closely. I didn't look for ones like i=i+2.
That would be 2% of the total. But the loops include a substantial proportion of fanciful for-headers, and the odd increment might relate to those.
Still, I was replying to someone suggesting my claim of "Any step other than 1 is unusual." was "Nonsense".
I suggest that 2-4% incidence is 'unusual'. In the two smaller programs I also looked at, of which I reported one, the incidence was 0% among /simple iterations/.