Break all, to leave any depth of loops

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
technicorn
Enthusiast
Enthusiast
Posts: 105
Joined: Wed Jan 18, 2006 7:40 pm
Location: Hamburg

Break all, to leave any depth of loops

Post 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
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post 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.
technicorn
Enthusiast
Enthusiast
Posts: 105
Joined: Wed Jan 18, 2006 7:40 pm
Location: Hamburg

Post 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
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Post 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.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Post Reply