[swift-evolution] [Idea] Wrap switch cases in curly braces

G B g.c.b.at.work at gmail.com
Thu Jul 7 15:43:38 CDT 2016


Braces don’t preclude using `break` or `continue`, why would they preclude `fallthrough`?


> On Jul 7, 2016, at 13:33 , Xiaodi Wu via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Fallthrough ceases to make much sense with braces, and it is a handy feature of switch statements every so often.
> On Thu, Jul 7, 2016 at 15:31 Roth Michaels via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> On Thu, Jul 07 2016 at 04:07:06 PM, G B via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> > I feel like this would be more consistent with the rest of the syntax:
> >
> > switch x {
> > case 0 { print(0) }
> > case 1 { print(1) }
> > case 2 { print(2) }
> > default { print("other”) }
> > }
> >
> > The colon syntax evokes a label, but the modern, complex `case`
> > statements in Swift don’t act much like labels.
> 
> I sort of see what you are saying about `case` not seeming like a label
> since we don't have GOTO in Swift.
> 
> I prefer the colon vs your brace suggestion, because from my
> perspective, the `switch` expression is the control flow statement and
> to the cases are like some sort of label even if they include complex
> pattern matching.
> 
> While Scala drops the colon to avoid case statements looks like labels,
> but uses => instead of whitespace and {} --- I prefer this to your
> suggestion, but as I said also think the colon is fine.
> 
> --
> Roth Michaels
> roth at rothmichaels.us <mailto:roth at rothmichaels.us>
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution <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/20160707/2216850e/attachment.html>


More information about the swift-evolution mailing list