Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: bart Newsgroups: comp.lang.c Subject: Re: Loops (was Re: do { quit; } else { }) Date: Wed, 16 Apr 2025 16:14:03 +0100 Organization: A noiseless patient Spider Lines: 33 Message-ID: References: <20250413072027.219@kylheku.com> <20250415053852.166@kylheku.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 16 Apr 2025 17:14:02 +0200 (CEST) Injection-Info: dont-email.me; posting-host="507c987f563baeac8cb4b74b82477869"; logging-data="2534687"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/gWwpjoBgLyiUnOem/6mZm" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:px68Hi9hfD5gijW1Y7SUZwy3WPc= In-Reply-To: Content-Language: en-GB Bytes: 2574 On 16/04/2025 15:47, James Kuyper wrote: > bart 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/.