> On 27 May 2016, at 15:31, plx via swift-evolution <swift-evolution@swift.org> 
> wrote:
> 
>   protocol Sequence {
>     typealias of<E> == S: Self where S.Iterator.Element == E
>   }
> 
>   // sequence-accepting variant
>   func doSomething<S:Sequence.of<Foo>>(values: S) { … }

This is a nice alternative; would it actually need to be declared in the angle 
brackets? Could it be done as:

        func doSomething(values:Sequence.of<Foo>) { … }

As long as it would work the same as a generic declaration this could be a good 
way to do it, either that or a SequenceOf type alias as mentioned.


Still, I kind of feel like we need to do something with the array type 
shorthand, but I wonder if perhaps we could just get rid of it altogether, to 
prevent its use entirely? i.e- all instances of [Foo] can be replaced with 
Array<Foo>, but we would encourage the use of 
Sequence.of/SequenceOf/Collection.of/CollectionOf first wherever possible.

As more types become available that are ArrayLiteralConvertible it seems like 
we should discourage restriction of a parameter to Array except when a 
developer explicitly chooses it. This problem will come up with the Dictionary 
type shorthand as well if Swift gets some kind of Map protocol to abstract it, 
and we don’t even have a Set-specific syntax so it seems like it may be fairer 
to remove these shorthands.
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to