[swift-evolution] Switch statement using blocks for conditions

Marco Scannadinari m at scannadinari.co.uk
Fri Dec 23 06:04:14 CST 2016


Hi,

I found it odd that the `label:` style is used for switch-case conditions,
considering that Swift does not have implicit fallthrough. To me the label
style only makes sense if you think of conditions essentially as labels for
a goto statement, which implies fallthrough.

Personally I think this syntax would make more sense:

switch condition {
  case 1 {
    //
  }

  case 2 {
    //
  }
}

This is how Rust implements match, although it is an expression so it
especially applies to that context. Nonetheless I think the above syntax
not only looks a lot nicer but makes more sense, especially since the
current syntax is the only instance where Python-style colons and
indentation are used for designating sections of code rather than braces.

Thoughts?

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


More information about the swift-evolution mailing list