In fact why not just use the generics syntax with protocols ? Anybody implementing a "Generic" Protocol has to specify the types.
protocol Collection<Key, Value > { func get(key: Key) -> Value? } class StringCollection: Collection<Key: String, Value: String> { } class GenericCollection<Type>: Collection<Key: Type, Value: Type> { } On Wed, Dec 23, 2015 at 11:18 AM, James Campbell <ja...@supmenow.com> wrote: > Maybe you could use the phrase "placeholder" type. If you think about it. > typealias is a way of "aliasing" the type. i.e "Type B is just another name > for Type C" > > Associated type I always found a bit confusing, associated with what ? A > placeholder type I feel explains it more plainly. Associated types are > nothing but placeholders. > > So this is my example: > > protocol Collection > { > typeplaceholder T > > func first() -> T? > } > > class IntCollection: Collection > { > typeplaceholder T = Int > } > > potentially you could provide some sort of syntax for setting it in the > subclass part of the code. > > > protocol Collection > { > typeplaceholder T > > func first() -> T? > } > > class IntCollection: Collection<T:Int> //The T type placeholder is now an > Int > { > > } > > class GenericCollection<F>: Collection<T:F> //The T type placeholder is > now what ever the generic F is set to. > { > > } > > On Wed, Dec 23, 2015 at 11:00 AM, Tino Heth via swift-evolution < > swift-evolution@swift.org> wrote: > >> >> > "Associated type" is the name of this feature >> The name of the concept is highly inexpressive, and I guess it's far >> easier to change the docs than to change the language… >> _______________________________________________ >> swift-evolution mailing list >> swift-evolution@swift.org >> https://lists.swift.org/mailman/listinfo/swift-evolution >> > > > > -- > Wizard > ja...@supmenow.com > +44 7523 279 698 > -- Wizard ja...@supmenow.com +44 7523 279 698
_______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution