[swift-evolution] Proposal: "break for", "break do", "break if", "break case", "break repeat", etc.

Jacob Bandes-Storch jtbandes at gmail.com
Wed Dec 9 17:28:00 CST 2015


I think "outer: for { ... { ... break outer } }" is significantly more
clear than a magical "break outer for" syntax that tries to describe in
English which loop to break out of.

Jacob Bandes-Storch

On Wed, Dec 9, 2015 at 3:23 PM, Amir Michail via swift-evolution <
swift-evolution at swift.org> wrote:

>
> On Dec 9, 2015, at 5:56 PM, Chris Lattner <clattner at apple.com> wrote:
>
>
> On Dec 9, 2015, at 1:26 PM, Amir Michail via swift-evolution <
> swift-evolution at swift.org> wrote:
>
> With such constructs, you could avoid using labels most of the time.
>
>
> Quick comment: this doesn’t eliminate the need for labels (since they
> provide the ability to break out of e.g. doubly nested for loops), but it
> does add complexity to the language.  As such, it doesn’t seem like a clear
> win to me.
>
>
> One of my examples has “break outer for”. I think it might be possible to
> eliminate labels completely with a reasonable looking syntax.
>
>
> -Chris
>
>
> For example:
>
> for … {
> if … {
>   guard … else { break if }
>   ...
> }
> }
>
> for … {
> for … {
>   if … {
>     break outer for
>   }
> }
> }
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
>
> _______________________________________________
> 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/20151209/b5810c4b/attachment.html>


More information about the swift-evolution mailing list