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

Austin Zheng austinzheng at gmail.com
Thu Dec 10 13:20:29 CST 2015

Indeed, you're right. If the do or if is nested within a loop the break works on the loop instead of the do/if.


> On Dec 10, 2015, at 11:12 AM, Kevin Ballard via swift-evolution <swift-evolution at swift.org> wrote:
> 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
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

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

More information about the swift-evolution mailing list