Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Bart Newsgroups: comp.lang.c Subject: Re: on allowing "int a" definition everywhere Date: Fri, 23 Aug 2024 12:25:32 +0100 Organization: A noiseless patient Spider Lines: 42 Message-ID: References: <998bef736d537e847808326b9d25a20cbeb2c6f4@i2pn2.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 23 Aug 2024 13:25:32 +0200 (CEST) Injection-Info: dont-email.me; posting-host="683b51147fd3c95c7018a07e9bc19669"; logging-data="951136"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+YsdhPRU9QrA36tqnuE3RV" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:xcnkMUUwD4hl8IFZuEfd97fcank= Content-Language: en-GB In-Reply-To: <998bef736d537e847808326b9d25a20cbeb2c6f4@i2pn2.org> Bytes: 2273 On 23/08/2024 11:47, fir wrote: > Bart wrote: > > btw maybe not so much relevent as what you write but > if to think the convention > > > foir(int i=0; i<100; i++) > { >   //,,, > } > > to amke int i scope relevant to only inner of the loop seem just > logically wrong Actually it's one of the few places it makes sense! But I don't like this idiom for several reasons. Sure, it can be convenient to write: for(int i=0; i<100; i++) without having to make an annoying detour to the top of the function to write that declaration for i. But then you need a second loop, and a third, and how you have to repeat a declaration each time: for(int i=0; i<200; i++) Better to do it once and forget about it. Then, it allows nested loops like this: for (int i = 0; i