Deutsch   English   Français   Italiano  
<vu5ems$230jl$4@dont-email.me>

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

Path: ...!weretis.net!feeder9.news.weretis.net!news.quux.org!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: Mon, 21 Apr 2025 13:46:21 +0100
Organization: A noiseless patient Spider
Lines: 93
Message-ID: <vu5ems$230jl$4@dont-email.me>
References: <vspbjh$8dvd$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> <vtnekn$1fogv$1@dont-email.me>
 <vto2mb$20c4n$1@dont-email.me> <vtu4i5$3hteg$1@dont-email.me>
 <vtujko$3uida$1@dont-email.me> <hxOMP.335104$j2D.272394@fx09.iad>
 <20250419092849.652@kylheku.com> <vu0t5m$22rjp$1@dont-email.me>
 <vu0v2n$22n7b$4@dont-email.me> <vu4cp5$3aou8$1@paganini.bofh.team>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 21 Apr 2025 14:46:21 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="519b62363da5fc709140aed5764e0c61";
	logging-data="2196085"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19K3UCOpi3Z49kdj+kOf34s"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:9b+c35+06aySFXhTM1R/BC4EMaM=
In-Reply-To: <vu4cp5$3aou8$1@paganini.bofh.team>
Content-Language: en-GB
Bytes: 5277

On 21/04/2025 04:07, Waldek Hebisch wrote:
> bart <bc@freeuk.com> wrote:
>> On 19/04/2025 20:22, James Kuyper wrote:
>>> On 4/19/25 12:36, Kaz Kylheku wrote:
>>>> On 2025-04-19, Scott Lurndal <scott@slp53.sl.home> wrote:
>>>>> bart <bc@freeuk.com> writes:
>>>>>> On 18/04/2025 19:10, James Kuyper wrote:
>>> ...
>>>>>>> If all you can do is "hope for the best", you're doing it wrong. It's
>>>>>>> your job to ensure that they are not arbitrary unrelated expressions,
>>>>>>> but correctly related expressions, and that's no different from your
>>>>>>> responsibility for all of the other expressions that make up your
>>>>>>> program.
>>>>>>
>>>>>>
>>>>>>
>>>>>> If you find that problematic, you shouldn't be programming in
>>>>>>> any language, but certainly not in C.
>>>>>>
>>>>>> I see it didn't take you long to get to the personal insult. What is it
>>>>>> with this group?
>>>>>
>>>>> It's not an insult, it is a simple fact.
>>>>
>>>> It's not a fact that someone who finds tools problematic shouldn't
>>>> be using them.
>>>
>>> I wasn't talking about him finding the tools problematic. I was talking
>>> aobut him find it difficult to ensure that the expressions are not
>>> arbitrary unrelated expressions, but are in fact correctly related
>>> expressions. If you cannot ensure that A, B, and C have the correct
>>> relationship to make for(A; B; C) work as needed, then you also lack to
>>> ability to make sure that the expressions in {A; B; C:} work together as
>>> needed, and that ability is fundamental to computer programming.
>>
>> In other words, the feature is dumb.
>>
>> The compiler cannot do any checking: for (i=0; i<n; ++n) is fine.
>>
>> Even in BASIC, if I do this:
>>
>>      for i=1 to n
>>      next n
>>
>> it will say that n does not match. And here it is optional; in C that
>> part is necessary.
>>
>> So, BASIC's for-loop is less dumb that C's.
>>
>> But, you have a bizarre take on this: if somebody calls it out, then
>> rather than agree with them, you will personally insult the person who
>> said it, and suggest that if they are incapable of such a simple check,
>> then they shouldn't be coding.
>>
>> The fact is that people make typos (obviously, not you or JP or SL or
>> KT!), and here you would really prefer that the compiler could report
>> them, but with this feature, it often can't.
> 
> There is low probablity of writing standard loop wrong and most
> people are not bothered that some errors are not detected at
> compile time.  If you are trouble by this, solution is simple:
> do not write 'for' loops different than the simple one:

What about when you're working with other people's code? Every for-loop 
you encounter is a little puzzle that you have to decode to find out its 
category! (There are about 4 categories plus 'free-style'.)

> If you are bothered that other people do not think that C
> flexibility is a problem, then you would need _much_ stronger
> argument, starting with some real data.

I don't now think think there is any argument that will make any 
difference. People here genuinely think that writing:

   for (ch = 0; ch <= 255; ++ch)

is far superior to this 'primitive' version:

   do ch = 0, 255

No amount of discussion or arguments will make them change their minds.

(BTW I had to fix two typos in the C, as in the first version I 
initially used 'ch, c and c'!)

Apparently, the C form is superior because that construct can also be 
used to conveniently express link-list traversal, and a lot more.

Even the idea of having *two* kinds of loop, one as it works now, and 
one more streamlined, was not acceptable: too much 'overloading' of the 
language.