Re: [swift-evolution] Union instead of Optional

2016-05-16 Thread Cao Jiannan via swift-evolution
Consider this case: class A { var someCommonProperty: Int = 0 } class B { var someCommonProperty: Int = 0 } class C { var someCommonProperty: Int = 0 } protocol UnionABC { var someCommonProperty: Int } extension A: UnionABC {} extension B: UnionABC {} extension C: UnionABC {}

Re: [swift-evolution] Union instead of Optional

2016-05-16 Thread Austin Zheng via swift-evolution
I'm sorry, but I don't understand the point you are trying to make. If you pass in a value of type (A | B | C) to a function, what might you want to do with that value? If you want to do one thing if the value is type A, something else if the value is type B, and something else if the value is

Re: [swift-evolution] Union instead of Optional

2016-05-16 Thread Austin Zheng via swift-evolution
I like the justification of unions as lightweight restricted ad-hoc enums. Definitely agreed with you in that the compiler will have to do more work, and should be able to handle the implicit conversion without going bonkers. Thanks! Austin > On May 16, 2016, at 3:35 AM, Haravikk

Re: [swift-evolution] Union instead of Optional

2016-05-16 Thread Cao Jiannan via swift-evolution
Hi Austin, let me repeat the example so that clarify my point from this example. protocol cannot do this: func input(value: ProtocolForABC) { print(value.someCommonProperty) if value is A { } else if value is B { } else if value is C { } else {

[swift-evolution] [proposal] Union Type

2016-05-16 Thread Cao Jiannan via swift-evolution
Union is far better then generic enum/protocol solution. * It can extend the original enum and make it powerful. enum ResultDataType { case Music case Video case File } enum FailureType { case HTTP404 case HTTP502 } enum FailureTypev2 { case

Re: [swift-evolution] Should we rename "class" when referring to protocol conformance?

2016-05-16 Thread Vladimir.S via swift-evolution
FWIW, totally agree with this opinion. I also don't understand why "poor beginner who would start typing swift code before reading the manual" becomes so important when we decide to accept or not some new feature or change. Are we working on language that must be used just to teach

<    1   2