5 ms·
"while" describes itself particularly poorly for native English speakers. It implies a duration that continues until a condition changes, but really the condit
by dkarl 6y ago
"while" describes itself particularly poorly for native English speakers. It implies a duration that continues until a condition changes, but really the condition is only checked at the beginning of every loop. English speakers have to get over the incongruity using a word for a contiguous period of time to indicate repeated checks at distinct points in time.
- nmeofthestate 6y agoJust speaking personally as a native English speaker, I don't remember ever having expended any effort to get over that incongruity.
- dkarl 6y agoI think it's something that only makes sense after the imperative model clicks. There are a lot of different ways that a beginner might think about what code means, and some beginners write code like this: while guessing == true: ... if is _correct(answer): guessing = false // This stops execution and jumps out of the loop, right? answer = next_guess() ... // answer should be correct now print('Correct answer is %s' % answer) The program says this block of code executes "while" guessing is true. How does it make sense that code inside the loop is still executing after guessing is set to false? For you and me, since our brains have been molded to the the imperative model of programming (execute this line, then this line, then this line,) we understand that "while guessing == true:" is a line of code that only has effect at specific times, "when the program gets to it." That is not what "while" means in ordinary language, so it's confusing for a beginner until the imperative model is really locked into their heads.