Path: csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: Loops (was Re: do { quit; } else { }) Date: Sun, 04 May 2025 07:31:11 -0700 Organization: A noiseless patient Spider Lines: 28 Message-ID: <86h62078i8.fsf@linuxsc.com> References: <87a58mqt2o.fsf@nosuchdomain.example.com> <20250413072027.219@kylheku.com> <20250415153419.00004cf7@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Sun, 04 May 2025 16:31:12 +0200 (CEST) Injection-Info: dont-email.me; posting-host="f2e2a4892b4200c8deca4768c4473856"; logging-data="2179137"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19yQTuU+1DOjJkiGI3ibk72TliAMql/QGk=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:kFR6a7HCzIIYIQDzdxleqJrA5e4= sha1:o0qKI4N9VDshNL1RV/Fvy2AGrCo= Xref: csiph.com comp.lang.c:393137 Michael S writes: > On Tue, 15 Apr 2025 11:30:24 +0100 > bart wrote: > >> Let me ask you this: what exactly is the point of the 'while' >> statement in C? Since it can always be trivially be written as: >> >> for (;cond;) >> >> It seems to that most use cases (initialise, check exit condition, >> change something that affects the letter), would suit 'for' better. >> >> But since 'for' then becomes overloaded, there ought to be a >> dedicated feature for simple iteration. So it seems the solution is >> as a I suggested above. > > I suspect that 'while' loop is here in C because Dennis Ritchie wanted > 'do .. while() ' and thought that if the keyword is here anyway than > why not reuse it? According to K&R, all of the basic control structures in C -- if, while, for, do, and switch (and listed in that order) -- were provided in BCPL, though not using the same syntax as in C,. > In the hindsight, probably a mistake. I admit I don't understand this reaction.