[swift-evolution] Require parameter names for ENUM Associated Types?

Adrian Zubarev adrian.zubarev at devandartist.com
Tue Nov 29 07:55:35 CST 2016

I’d rather would have the ability of overloading enum cases:

enum MyEnum {
    case a
    case a(Int)
    case a(label: Int)
    case a(Double)
I don’t know how enums work internally, but I spotted a bug recently where the compiler does not allow to declare a function with the same name as an enum case.


I think this is a side effect of this proposal https://github.com/apple/swift-evolution/blob/master/proposals/0036-enum-dot.md

Adrian Zubarev
Sent with Airmail

Am 29. November 2016 um 14:48:30, Steve Prescott via swift-evolution (swift-evolution at swift.org) schrieb:

Has there been any discussion of REQUIRING names for associated types in an enum?

Current	= “case error (String, Int)”	// No names
Proposed = “case error (errorString: String, errorCode: Int)”	// Has names

I know that Swift allows this today — optionally. To me, it seems that requiring the parameter names would be more consistent with func syntax. The current syntax (defaulting to no names) leads to declaration of vars that look C-like, to me:

let myResult = Result.error (“It failed”, -999)

swift-evolution mailing list
swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161129/43138e75/attachment.html>

More information about the swift-evolution mailing list