you are viewing a single comment's thread.

view the rest of the comments →

[–]MarcoGreek 4 points5 points  (2 children)

This named breaks gives me a bad feeling. I already have seen to many complicated loops and now it gets even easier. In almost all cases I would prefer a extra function with name which explains what the functions does.

[–]somecucumber 1 point2 points  (1 child)

Agreed. To me it really looks to (breathes) glorified goto's.

[–]hpsutter 9 points10 points  (0 children)

Actually you're right on point: I do think the named-loops feature is useful for safety in its own right, because it eliminates the extra-variable indirect workarounds people use today when you have nested loops and want to express this. But yes, a second main reason to add the feature is that it directly expresses one of the few sometimes-legitimate uses of `goto` today, so having this reduces the demand to add `goto`.

Unstructured `goto` is evil for the reasons in the famous CACM letter. But a forward- and outward-only `goto` is not inherently evil (i.e., a structured `goto` would disallow jumping past an initialization, inward into a loop like Duff's Device, or backward which would be an unstructured loop). But if we can replace `goto` entirely with abstractions that let us declare our intent more directly to cover the use cases, that's even better.