We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Bug or feature: break with label
Page Index Toggle Pages: 1
Bug or feature: break with label (Read 478 times)
Bug or feature: break with label
Jun 9th, 2006, 5:16pm
 
I was trying to break out of nested for loops using the Java feature of a labeled statement like this:

OUT:
 for (...)
   for (...)
   {
     ...
     break OUT;
   }

Unfortunately the Processing IDE seems to omit the whole loop when compiling it to Java.

Since labeled break is not documented in the Processing reference, one probably can't consider this behavior a bug. But it certainly is a very unexpected feature. Or am I missing something else?


Harald
Re: Bug or feature: break with label
Reply #1 - Jun 9th, 2006, 6:34pm
 
Wow, I didn't even realize that Java had a break with labels feature. That kind of thing is a throw-back to BASIC and Assembler, and frowned upon by any "serious" programmer.

You might want to have a look at the following link: Branching Statements. It indicates that your use of labels is correct, and I have no idea why Processing does not compile it. However, I would recommend that rather than trying to find a fix for the label behavior you try to do what you intend without resorting to labels.

"break" and "continue" are generally considered fine and are sometimes required, as in the "switch" statement. But I would recommend using boolean variables as flags to control branching behavior, you should be better off with that than with using labels.
Page Index Toggle Pages: 1