Timeline for provability of while loop vs for loop
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 27, 2015 at 7:54 | comment | added | JᴀʏMᴇᴇ | On the contrary, the code you've written proves that there's a guarantee your condition variables WILL be tampered with. I don't understand this answer. | |
Apr 21, 2015 at 10:19 | comment | added | Mike Nakis | @gbjbaanb true, but as far as the question is concerned, it is a far cry from principle of least astonishment to provability. | |
Apr 21, 2015 at 9:42 | comment | added | gbjbaanb | @VincentAdvocaat I'd say that with a while loop you expect the condition variable to be tampered with in some way, whereas a for loop you expect it to be changed only in the step part of the for loop construct itself. This principle of least astonishment is more important than many realise in programming. | |
Apr 21, 2015 at 9:31 | comment | added | Vincent | James could you perhaps elaborate why this is less of an issue for while loops, you might be on to something however people seem to disagree for a lac of counter evidence in the case of while loops | |
Apr 21, 2015 at 9:25 | comment | added | Mike Nakis |
Oh yeah? Whereas, with while loops you can actually guarantee that the condition variable has not been tampered with? In fact, tampering with the condition variable is the only way to break out of a while loop! I usually refrain from downvoting stuff, but for this answer, I shall make an exception.
|
|
Apr 21, 2015 at 9:25 | comment | added | milleniumbug |
How does that make while loops fare better here?
|
|
Apr 21, 2015 at 9:23 | history | answered | James Anderson | CC BY-SA 3.0 |