[swift-evolution] [Pitch] merge types and protocols back together with type<Type, Protocol, ...>
adrian.zubarev at devandartist.com
Sat May 14 03:23:38 CDT 2016
I apologize for any possible flood (if there is any restriction in this mail list).
One other example that comes to mind, where I can’t really tell if this would be possible to express with `struct<>`, can be defined outside of the generic scope just like `class<SomeBaseClass, SomeProtocol>` or `all<SomeBaseClass, SomeProtocol>`:
var structArray: [struct<Any, SomeProtocol>]
Would this work? This is an interesting case, where no values inside the struct can be reference-types!
Actually I can answer this question by myself, because `Any` is just a typealias for `protocol<>` and does not violate any rule here.
This also adds a few more type combinations I missed out in my proposal:
e.g. `struct<Any>` is equivalent to `struct<protocol<>>`
This can allow us to use any struct without the need of generic scope! Isn’t it great or what?
Have you ever wanted to store any class references with conformance to a protocol without the generic system, with this you could do so `class<Any, SomeProtocol>`:
var classArray: [class<Any, SomeProtocol>]
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution