[swift-evolution] [Review] SE-0036: Requiring Leading Dot Prefixes for Enum Instance Member Implementations

Dany St-Amant dsa.mls at icloud.com
Tue Apr 5 07:31:22 CDT 2016


> Le 31 mars 2016 à 23:41, Douglas Gregor via swift-evolution <swift-evolution at swift.org> a écrit :
> :
> https://github.com/apple/swift-evolution/blob/master/proposals/0036-enum-dot.md

Wondering if this fit more in the lexer/in-house coding style bucket.
For the supplied example of "badness", 'case heads', one can also write 'case Coins.heads' and with the latest Erica's pitch, one day 'case Self.heads'; are these also going to be disallowed?
I have always seen, the leading dot as an opt-in shortcut that the parser allowed us to use when the context/type can be inferred, and as such the usage of leading dot should probably be left to the user.

The problem I see from the example, is not the inconsistency with 'case heads' vs 'case .tails' (as coding style) but that you can define in the enum:

static let bluenose:Coin = .tails

And then use it  in:
var coin:Coin = .bluenose
if coin == .bluenose { print("tails") }

But not in:
switch coin {
    case .bluenose: print("tails")
    default: print("heads")
}

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


More information about the swift-evolution mailing list