[swift-evolution] Proposal: Replace labels with keywords and "*" suffixes

Kevin Ballard kevin at sb.org
Thu Dec 10 13:12:50 CST 2015

On Thu, Dec 10, 2015, at 11:05 AM, Austin Zheng via swift-evolution wrote:
> Unlabeled "break" within a do is a compiler error, even if the do is
> nested within a different control flow.

No it's not. The following compiles just fine (in Swift 2.1 and
Swift 2.2-dev):

repeat {    do {        break    } } while true print("done")

But I don't think that's a problem. There's tons of precedent for
unlabelled break breaking out of the nearest enclosing loop rather than
the nearest enclosing scope. And people are generally going to learn
about unlabelled break before labelled break. The fact that you can
label a do {} and break out of it is interesting, but shouldn't change
the expected behavior of unlabelled break.

-Kevin Ballard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151210/0952c969/attachment.html>

More information about the swift-evolution mailing list