[swift-evolution] generic associatedtype?
Jens Persson
jens at bitcycle.com
Sat Sep 17 17:37:44 CDT 2016
Has there been any discussions about the possibility of having generic
associatedtypes?
I (naively) think that it would open up a lot of possibilities.
Because if, for example, we could do this:
protocol CountType {
associatedtype Storage<E>
...
}
Then we could do this:
struct Count1 : CountType {
typealias Storage<E> = (E)
...
}
struct Count2 : CountType {
typealias Storage<E> = (E, E)
...
}
struct Count3 : CountType {
typealias Storage<E> = (E, E, E)
...
}
...
protocol StaticArrayType {
associatedtype Count: CountType
associatedtype Element
...
}
struct StaticArray<C: CountType, Element> : StaticArrayType {
typealias Count = C
var storage: C.Storage<Element>
...
}
Would adding support for generic associatedtypes be possible? Are there any
plans for it?
(
I tried searching for it but I found only this:
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160411/015089.html
)
Thanks,
/Jens
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160918/94f5b37f/attachment.html>
More information about the swift-evolution
mailing list