break while; break for; break foreach

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Thu May 13 20:27:14 UTC 2021


On Thursday, 13 May 2021 at 19:36:28 UTC, Steven Schveighoffer 
wrote:
> D already does this, you can break using a label. The problem 
> I've had with it is that a label cannot be repeated within a 
> function, so it's hard to write generic code which requires 
> this feature.

Reusing keywords for different things is not a good idea as it 
makes code harder to skim through (harder to read fast).

If this is only for generic programming, how about a way to break 
N scopes out and make that N a compiletime expression?

So break(1) would jump 1 scope out, break(2) would jump 2 scopes 
out etc. Maybe overkill.


More information about the Digitalmars-d mailing list