Multi-Level Break?

Vladimir Panteleev thecybershadow at gmail.com
Sat Jan 6 21:49:27 PST 2007


On Sun, 07 Jan 2007 07:41:28 +0200, Xinok <xnknet at gmail.com> wrote:

> I'm sure this is something that has been discussed time and time again,  
> but I think D should have a multi-level break. I don't know PHP well,  
> but I found out it it's one of a few languages (if not the only  
> language) that has this feature. Example here:
> http://phpbuilder.com/manual/control-structures.break.php
>
> break 2; // Multi-Level Break
>
> This is something which could also be applied to the continue keyword:
> continue 2; // Breaks the current loop, and continues the outer loop

Check this out:

http://www.digitalmars.com/d/statement.html#LabeledStatement
http://www.digitalmars.com/d/statement.html#BreakStatement

D allows you to specify labels for loops, and break out of them.
Although it requires you to define a label, the code is more flexible - if  
you happen to add or remove some loops between the break and the loop  
you're breaking out of, you'd have to update all breaks - and I'm sure  
this is a cause of bugs in PHP.

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/



More information about the Digitalmars-d mailing list