[swift-evolution] [Idea] Allowing most keywords after "."

Stephen Celis stephen.celis at gmail.com
Sat Feb 27 08:05:19 CST 2016


> On Feb 27, 2016, at 8:37 AM, Radosław Pietruszewski via swift-evolution <swift-evolution at swift.org> wrote:
> 
> +1, that makes a lot of sense.
> 
> Q: Is `case default` in enum context ambiguous? In case I’m forgetting something, `default` is only used in `switch` contexts. So… couldn’t we make the keyword context dependent?

According to the grammar, `default` is indeed only used in `switch`: https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html#//apple_ref/swift/grammar/default-label

I have two thoughts:

1. Is it possible to reconsider reusing another keyword, `else`, as Ruby does?

2. Could the parser scan the leading `.` to prevent the need for escaping cases named "default", or would this unnecessarily complicate the compiler?

--
Stephen


More information about the swift-evolution mailing list