Groups | Search | Server Info | Login | Register


Groups > comp.lang.c > #393206

Re: Loops (was Re: do { quit; } else { })

Path csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups comp.lang.c
Subject Re: Loops (was Re: do { quit; } else { })
Date Tue, 06 May 2025 05:59:20 -0700
Organization A noiseless patient Spider
Lines 47
Message-ID <86ecx13nfb.fsf@linuxsc.com> (permalink)
References <vspbjh$8dvd$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> <ISOLP.1774061$FVcd.178862@fx10.iad> <20250416173721.000030b5@yahoo.com>
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Injection-Date Tue, 06 May 2025 14:59:21 +0200 (CEST)
Injection-Info dont-email.me; posting-host="f84420402be78ce51ba0e8f0077f27e2"; logging-data="3118472"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/x7s7gnwj0CN9pWsPR2Ekr7Gm/oqkd8qM="
User-Agent Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock sha1:hKyV0NKWaKv/omMPIlLJVKPlNGg= sha1:XinHTndNhsx6okJZEKRIp3z3wLw=
Xref csiph.com comp.lang.c:393206

Show key headers only | View raw


Michael S <already5chosen@yahoo.com> writes:

> On Wed, 16 Apr 2025 14:09:44 GMT
> scott@slp53.sl.home (Scott Lurndal) wrote:
>
>> bart <bc@freeuk.com> writes:
>>
>>> On 15/04/2025 20:07, Scott Lurndal wrote:
>>>
>>>> bart <bc@freeuk.com> writes:
>>>>
>>>>> On 15/04/2025 14:19, Kaz Kylheku wrote:
>>>>>
>>>>> Thats's fine.  But it means a real 'for' loop doesn't exist in C;
>>>>> you have to emulate it using that 3-way construct, which is naff,
>>>>> and also error prone.
>>>>
>>>> Real for loops _are_ a three-way construct.
>>>>
>>>> 135 FOR I=1 TO 10 STEP 2                              [BASIC]
>>>>
>>>>      for(i = 1; i < 11; i += 2)                        [C/C++]
>>>>
>>>>      do 1 = 1, 10, 2                                   [FORTRAN]
>>>
>>> Any step other than 1 is unusual.  So Basic and Fortran would
>>> typically be:
>>>
>>>     for i = 1 to 10     # 6 tokens;  Basic
>>>     do  i = 1, 10       # 6 tokens;  Fortran
>>>     for i = 1, 10       # 6 tokens;  Lua
>>>     for i to 10 do      # 5 tokens;  Mine (using default start)
>>>     to 10 do            # 3 tokens;  Mine (when index is not needed)
>>>
>>> Let's look at that C again:
>>>
>>>     for (int i = 1; i < 11; i += 1)  # 15 tokens;  C
>>
>>   for(i = 1; i++ <= 10;)
>
> I'd reject this code during review.
> Hopefully, you too.

I'm curious to know the basis for your reaction.  What about the
code would prompt your judgment to reject it?  Is it just a
specific reaction, or does it represent some more general pattern
(and if so then what more general pattern)?

Back to comp.lang.c | Previous | NextNext in thread | Find similar


Thread

Re: Loops (was Re: do { quit; } else { }) Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-05-06 05:59 -0700
  Re: Loops (was Re: do { quit; } else { }) Michael S <already5chosen@yahoo.com> - 2025-05-07 12:32 +0300
    Re: Loops (was Re: do { quit; } else { }) Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-05-07 14:54 +0200
    Re: Loops (was Re: do { quit; } else { }) scott@slp53.sl.home (Scott Lurndal) - 2025-05-07 13:50 +0000
    Re: Loops (was Re: do { quit; } else { }) Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-05-11 23:48 -0700

csiph-web