[swift-evolution] Proposal: Replace labels with keywords and "*" suffixes
Austin Zheng
austinzheng at gmail.com
Thu Dec 10 13:05:55 CST 2015
Unlabeled "break" within a do is a compiler error, even if the do is nested
within a different control flow.
If you really hate coming up with label names, just start with L1 and start
counting up. If you really need to come up with that many labeled breaks in
your code, though, I would invite you to step back and think about whether
or not you could refactor your control flow in a way that makes it easier
for others to understand.
Austin
On Thu, Dec 10, 2015 at 5:28 AM, Amir Michail via swift-evolution <
swift-evolution at swift.org> wrote:
>
> > On Dec 10, 2015, at 8:20 AM, Kevin Wooten <kdubb at me.com> wrote:
> >
> > Curios as to what you see the advantage of this is, over labels? Seems
> to me it only saves a few keystrokes at the expense of clarity.
>
> What “break" currently does can be unclear. For example, “break” without a
> label in do {…} doesn’t just break out of the do.
>
> Also, I really don’t like coming up with label names. They tend to be
> uninteresting.
>
> >
> > Given the stated goals of Swift I don’t imagine this would be an
> interesting proposal for many.
> >
> >> On Dec 10, 2015, at 5:59 AM, Amir Michail via swift-evolution <
> swift-evolution at swift.org> wrote:
> >>
> >> For example:
> >>
> >> for* … {
> >> for** ... {
> >> for ... {
> >> …
> >> if … { break for* }
> >> ...
> >> if … { continue for** }
> >> ...
> >> }
> >> }
> >> }
> >>
> >> repeat {
> >> do {
> >> for … {
> >> if … { break do }
> >> if … { continue repeat }
> >> }
> >> …
> >> }
> >> } while …
> >>
> >>
> >> _______________________________________________
> >> 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/20151210/b07cc4de/attachment.html>
More information about the swift-evolution
mailing list