Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: rbowman Newsgroups: comp.os.linux.setup,comp.os.linux.advocacy,sci.physics Subject: Re: I think in FORTH & program in C/C++. Date: Sun, 3 Oct 2021 19:47:05 -0600 Lines: 49 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net lRatPb938Wc6rIBXnHq72gtulhxYvWJiKmzExedu/yg9Y4+cEc Cancel-Lock: sha1:+rScqeq9XMt6Byy3YZXzPpi9ICI= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 In-Reply-To: Xref: csiph.com comp.os.linux.setup:4713 comp.os.linux.advocacy:595232 sci.physics:833655 On 10/03/2021 07:02 PM, Clutterfreak wrote: > On 10/3/2021 12:49 PM, rbowman wrote: >> On 10/02/2021 11:12 PM, Clutterfreak wrote: >>> >>> There's not a repetition that a do/while or a while loop can perform >>> that cannot be performed by a for loop as efficiently and as clearly. >>> I've not, in my life, used any loop that had a "while" in it in any of >>> the few languages that I programmed with. I only see the word "while" in >>> programming books and hear it others mentioning it. So it is not needed. >>> It is just another alternator doing what alternators do. >> >> for (; test; ) { >> .... >> test = pigsFly(); >> } >> >> static int pigsFly(void) { >> return 0; >> } >> >> >> Congratulations! You've created a while loop assuming test is true at >> the onset. When you only have a hammer... >> >> Sooner or later it comes down to >> >> JZ get_me_out_of_here >> > > > Why would you want to use a for loop when you want block only to run once? > The ... ellipses assumed several complex blocks, one path of one which included questioning if pigs can fly and there was no iteration such as for (i=0; i<=number_of_pigs; i++) { if (!can_pig_n_fly(i) break; } int can_pig_n_fly(int i) { if (moon_is_blue && i == 13) return 0; return 1; } I'm not arguing that you can't create the equivalent of a while loop with a for loop or that you can't use a screwdriver as a chisel.