?

Log in

No account? Create an account

Previous Entry | Next Entry

continue;

Who came up with the semantics of the continue keyword in loop constructs?

The continue keyword is used to jump to the next iteration of a for or while loop - skipping the rest of the statements in the current iteration.  The dictionary defines continue as "To go on with a particular action or in a particular condition; persist".  These two concepts are in direct opposition to each other.  The continue keyword should really be skip or next or something, which would more clearly mean "stop the current iteration of the loop, and move on to the next one".


Comments

( 3 comments — Leave a comment )
toob
Dec. 20th, 2007 09:48 pm (UTC)
It all depends on what you're applying the word "continue" to. If it's to the current iteration, then yeah, it's illogical, but if it's to the next step of the loop, then it makes sense.

It works better if you think of the iteration as a single step in a set of instructions. If you continue the instructions, that doesn't mean you keep repeating the same step, it means you continue on to the next.
wolffit
Dec. 21st, 2007 02:37 pm (UTC)
Oh, I understand that, and from that perspective it does make sense, but coding is supposed to be unambiguous! I don't think of the iteration as a single step in a set of instructions, I think of it as a block of instructions. :-)
unbleachedbrun
Dec. 20th, 2007 09:57 pm (UTC)
Al Gore came up with that back when he was inventing the Internet.
( 3 comments — Leave a comment )

Profile

Galen
wolffit
Galen Wolffit

Latest Month

November 2015
S M T W T F S
1234567
891011121314
15161718192021
22232425262728
2930     
Powered by LiveJournal.com
Designed by Tiffany Chow