[swift-evolution] Proposal: Remove the "fallthrough" keyword

Dave Abrahams dabrahams at apple.com
Sun Jan 22 18:53:22 CST 2017

Sent from my iPad

> On Jan 22, 2017, at 3:15 PM, Chris Lattner <clattner at nondot.org> wrote:
>>> On Jan 20, 2017, at 12:22 PM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
>>> Yeah, maybe there's a more general language feature that could replace 'fallthrough' here. Instead
>>> of labelling cases, we could support a 'reswitch' statement that redispatches the switch to the case
>>> matching the operand:
>>>    switch some_value {
>>>    case .REFINED:
>>>        if !validate(some_value) { return NULL }
>>>        reswitch .BASE
>>>    case .BASE:
>>>        handle_enum_value();
>>>    }
>> We should just call a spade a spade and spell that "goto" ;-)
> Goto has traditionally been used for unstructured control flow, but this form is still fully structured.  You cannot produce irreducible loops, jump into scopes, over declarations, etc.

It would be useful to know the technical definition of "structured." The fact is that there's a large category of sensible goto-like jumps that we probably want to allow and I see no advantage to giving them all distinct names.  I don't believe users will distinguish them.  We already have "break looplabel" and, aside from the label being in the wrong place, it's effectively a goto.  It seems to me we should just have goto and either prohibit the troublesome uses or give them reasonable semantics.

I could live with "break" as well as "goto", but it feels a bit like it's pretending to be something it isn't, and there's the source compatibility problem with the label position.

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

More information about the swift-evolution mailing list