From: Juha Nieminen on 2 May 2010 04:07 In comp.lang.c++ Richard Heathfield <rjh(a)see.sig.invalid> wrote: > Yes, and this question-begging is perfectly in keeping with the > requirement that one should never exit from within a loop. (It is, after > all, an argument about loops.) Out of curiosity: Why have the requirement that one should never exit from within a loop? Is there a rational reason to enforce this requirement even in cases where exiting from inside a loop would actually make the code simpler and easier to understand (and possibly more efficient)? It sounds to me like you are advocating a certain kind of programming paradigm as the silver bullet for all problems. As if sticking very strictly to that paradigm would always make your code better. There exists no such programming paradigm.
From: Keith Thompson on 2 May 2010 04:46 Richard Heathfield <rjh(a)see.sig.invalid> writes: > Seebs wrote: >> On 2010-04-28, Richard Heathfield <rjh(a)see.sig.invalid> wrote: [...] >>> In any case, your loop condition expressions do not correctly describe >>> the conditions under which the loop will terminate. Please rewrite your >>> example so that they do, and then by all means ask me again if you wish. >> >> I think the point was that he was asking *you* to rewrite the example >> so that the loop conditions correctly describe the conditions under which >> the loop will terminate. > > And we all know how that will go. I get the impression that you're implying something that you think is obvious, but I don't know what it is. We don't all know how that will go. In particular, I don't know how it will go, because you haven't shown us how you would write the loop. I'm curious. [...] -- Keith Thompson (The_Other_Keith) kst-u(a)mib.org <http://www.ghoti.net/~kst> Nokia "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"
From: Nick on 2 May 2010 05:13 Richard Heathfield <rjh(a)see.sig.invalid> writes: > Yes, and this question-begging is perfectly in keeping with the > requirement that one should never exit from within a loop. (It is, > after all, an argument about loops.) What requirement? If there was such a requirement, why is "break" allowed in any loop? Why is "return" allowed other that in the outermost block within a function. Either could easily have been made part of the standard if there was such a requirement. -- Online waterways route planner | http://canalplan.eu Plan trips, see photos, check facilities | http://canalplan.org.uk
From: bart.c on 2 May 2010 05:56 "Nick" <3-nospam(a)temporary-address.org.uk> wrote in message news:87iq76zmwc.fsf(a)temporary-address.org.uk... > Richard Heathfield <rjh(a)see.sig.invalid> writes: > >> Yes, and this question-begging is perfectly in keeping with the >> requirement that one should never exit from within a loop. (It is, >> after all, an argument about loops.) > > What requirement? > > If there was such a requirement, why is "break" allowed in any loop? > Why is "return" allowed other that in the outermost block within a > function. Either could easily have been made part of the standard if > there was such a requirement. It would have broken too much existing code. That's the usual reason. -- Bartc
From: James Kanze on 2 May 2010 06:07
On May 2, 8:34 am, Richard Heathfield <r...(a)see.sig.invalid> wrote: > Seebs wrote: [...] > Why not just write while(i < j && a[i] != 42)? Because it states the loop invariants up front, in a single statement, rather than making the maintenance programmer have to figure them out for himself. Maintenance programmers have it too easy. -- James Kanze |