Deutsch   English   Français   Italiano  
<vto4fu$23kmr$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: bart <bc@freeuk.com>
Newsgroups: comp.lang.c
Subject: Re: Loops (was Re: do { quit; } else { })
Date: Wed, 16 Apr 2025 12:32:13 +0100
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <vto4fu$23kmr$1@dont-email.me>
References: <vspbjh$8dvd$1@dont-email.me> <vtc7mp$2q5hr$1@dont-email.me>
 <vtcqf6$3j95s$1@dont-email.me> <vtdh4q$b3kt$1@dont-email.me>
 <vtf7fe$1qtpg$1@dont-email.me> <vtgfuf$31ug1$1@dont-email.me>
 <20250413072027.219@kylheku.com> <vtgpce$39229$1@dont-email.me>
 <vti2ki$g23v$1@dont-email.me> <vtin99$vu24$1@dont-email.me>
 <vtiuf0$18au8$1@dont-email.me> <vtj97r$1i3v3$1@dont-email.me>
 <vtl166$36p6b$1@dont-email.me> <vtlcg0$3f46a$2@dont-email.me>
 <20250415053852.166@kylheku.com> <vtm4ae$6d5j$1@dont-email.me>
 <H7yLP.2056536$OrR5.1414451@fx18.iad> <vtmgj8$g81k$1@dont-email.me>
 <vtnfjj$1gk91$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 16 Apr 2025 13:32:14 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="507c987f563baeac8cb4b74b82477869";
	logging-data="2216667"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/JFvKxCV9+dghcYFAOBDDi"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:a1xOSU+Kq8i9IAwPX8edQ+9yQWw=
Content-Language: en-GB
In-Reply-To: <vtnfjj$1gk91$1@dont-email.me>

On 16/04/2025 06:35, Janis Papanagnou wrote:
> On 15.04.2025 22:46, bart wrote:
>> On 15/04/2025 20:07, Scott Lurndal wrote:
>>> [...]
>>> Real for loops _are_ a three-way construct.
>>>
>>> [...]
>>
>> Any step other than 1 is unusual. [...]

> Nonsense. Arithmetic loop steps other than one are noting unusual
> and been supported by programming languages (and also been used)
> since decades in programming.

So what are you claiming, that the majority of loops in any given 
program will have steps other than +1 or -1?

THAT would be nonsense! For your benefit, I've done a survey of a 30Kloc 
C program (not one of mine). It has 181 for-loop statements, of which:

   15       are endless loops (for (;;))
   23       are either linked traversal or do something weird
  143       seems to be simple integer interations

Of those 143, 137 count upwards with a step of +1; 6 count downwards 
with a step of -1.

So here, 0% of such loops have a step other than 1. THAT's what I mean 
by 'unusual'.

Scot Lurndal gave examples comparing C with BASIC/FORTRAN that used 
steps other than one, to back up a claim that they routinely use 3 
components. Actually they rarely do.

There is something else: all 181 of those loops used the 'for' keyword. 
Which meant I had to painstakingly analyse them one by one to determine 
what they were (and probably overlooked some but the figures will be 
close enough).

Written in my language, 15 would be 'do' loops; 23 would likely be 
'while' loops; and only those 143 would be 'for' loops.

No analysis necessary.

But never, mind, C's for-loop will still be the most superior to 
everybody here. I'd have an easier time arguing about religion!