>
>
> > In fact why not just use the generics syntax with protocols ?  Anybody
> implementing a "Generic" Protocol has to specify the types.
> That's a simple solution, but inconvenient:
> One use case for placeholders (I don't use the official name here to
> propagate an alternative ;-) is when you have a types that depend on a
> parameter.
> I'm to lazy to look up a real example, but Array<Int> is naturally
> associated with an enumerator for Int — and it is no fun to be forced to
> include such relationships all over the place.


So in my example with placeholders.

class GenericCollection<Type>: Collection<Key: Type, Value: Type>
{

}

Has already specified the type of the placeholder :) so subclasses don't
need to specify it. In this example the Key and Value type placeholders are
bound to whatever the Type is.

So in these examples

let items: GenericCollection<Int> = GenericCollection()

or

let items: [Int] = []

the Key and Value type placeholders would be Ints :) since the generic type
is an Int.


-- 
 Wizard
[email protected]
+44 7523 279 698
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to