Page 1 of 1
Break all, to leave any depth of loops
Posted: Fri Dec 12, 2008 8:41 pm
by technicorn
I wish for a 'All' option for Break to leave any nesting depth of loops,
without having to specifiy the exact level number.
Of course, this should be restricted to levels either within a procedure
or loops on the main program level.
Happy 3. Advent
Technicorn
Posted: Sat Dec 13, 2008 9:37 am
by Rescator
Can't say I'm fond of that, it's as bad as GoTo and similar.
If you have that many nested loops that you need to break out of then your really need to redesign the way the code works as it sounds very inefficient and overly complicated.
Posted: Sat Dec 13, 2008 1:47 pm
by technicorn
Hi Rescator
can't see the connection of goto to break.
Break is meant to be a clean way to leave a loop,
or how would you end a loop if you, for example, has used it to scan a list
and found the searched item and want to leave the loop?
Or a parser for a language like Basic, how would you propagate an error up to the toplevel of the parser,
if you find the 10. parameter in the 33. nested include file has a wrong typ, for example?
Greetings
Technicorn
Posted: Sat Dec 13, 2008 1:53 pm
by c4s
He said that if you have too many loops for which "break 2" isn't enough
then there is something wrong with your code.