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

Adrian Zubarev adrian.zubarev at devandartist.com
Tue Nov 29 09:52:17 CST 2016


I just showed a direction of what could be possible.

Personally I think it would be enough if we had this:

enum MyEnum {
     
    case a
    case b(Int)
    case b(Int, string: String)
}  
Where .b can be overloaded by it’s associated types.



-- 
Adrian Zubarev
Sent with Airmail

Am 29. November 2016 um 16:48:34, Karl (razielim at gmail.com) schrieb:


On 29 Nov 2016, at 14:55, Adrian Zubarev via swift-evolution <swift-evolution at swift.org> wrote:

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.

SR–3256

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



eek… I really would not like that at all.

if case .a(let value) = myEnumValue {
    // what is type(of: value)?
}

- Karl

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


More information about the swift-evolution mailing list