D vs C++

Walter Bright newshound2 at digitalmars.com
Sun Dec 26 02:38:53 PST 2010


Daniel Gibson wrote:
> I don't think so. They're much more clean and readable than goto (they 
> just restart/jump behind the current loop or, if you use them with 
> labels, an outer loop - IMHO that's quite different from jumping to 
> arbitrary labels).
> I guess this is the reason why break and continue are supported in Java 
> but goto isn't.

Use of break and continue guarantee two important characteristics over goto:

1. initialization of a variable cannot be skipped

2. loops can only have one entry point

The latter is called having a "reducible flow graph", which is an important 
requirement for many optimizations. (1), of course, can hide an ugly problem.


More information about the Digitalmars-d mailing list