Deutsch   English   Français   Italiano  
<vtu22g$3f353$1@dont-email.me>

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

Path: ...!eternal-september.org!feeder3.eternal-september.org!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: Fri, 18 Apr 2025 18:27:44 +0100
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <vtu22g$3f353$1@dont-email.me>
References: <vspbjh$8dvd$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> <vto4fu$23kmr$1@dont-email.me>
 <878qnz27sj.fsf@nosuchdomain.example.com> <vtpa3u$357ma$1@dont-email.me>
 <87r01rzl89.fsf@nosuchdomain.example.com> <vttkio$34as4$1@dont-email.me>
 <vttn1n$3468v$1@dont-email.me> <TwvMP.2107973$eNx6.755301@fx14.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 18 Apr 2025 19:27:45 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="225decbae7f6d1b66db568edbb209aee";
	logging-data="3640483"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19YE0IFKMbMV7VkcqlyZ8VY"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:XCVK+oFqFhend5Qt46TQa3gqWLw=
Content-Language: en-GB
In-Reply-To: <TwvMP.2107973$eNx6.755301@fx14.iad>
Bytes: 3318

On 18/04/2025 17:58, Scott Lurndal wrote:
> bart <bc@freeuk.com> writes:
>> On 18/04/2025 14:37, Janis Papanagnou wrote:
> 
>>
>> * Scott Lurndal (SL) makes a claim that all 'real' for-loops have 3
>>    parts, like C's for(A; B; C) [point 1]
> 
> Again you mischaracterize what was stated.    I simply
> pointed out that most major programming languages have three component
> looping constructs using the 'for' keyword, including C.

Apart from C, simple iteration via a loop index has 4 things that need 
to be denoted:

  - Some keyword to say this is such a loop

  - The loop index variable

  - The start value

  - The end value

Many can have an /optional/ step (or means to reverse the order) in the 
odd cases where that is necessary, making 4/5 if you want to be formal.

C is quite different; it is merely 3 arbitrary expressions, the middle 
one of which is used as a loop terminating condition (tested notionally 
at the start of the loop).

But in cases where it is used to emulate the kind of loop described 
above, then the same applies, except that:

   - It will always be 5 parts (the step always has to be accounted for)

   - Nearly everthing about how it works has to be imparted to the
     compiler:
     - The actual expression to initialise the variable
     - The exact expression used for the terminating condition
     - The exact expression used for incrementing to loop index

   - The end value that appears in the terminating condition is
     frequently offset (also can also be the case in real for-loops
     used in 0-based languages)

   - A loop which counts down may well have a quite different pattern
     from an upward counting one

So a comparison between C for-loops and more formal ones is not that 
meaningful.