> This almost seems like it could work so that it didn't even need the
> bracketed parts to be able to figure out the types:
>
> func anyCommonElements(lhs: T, _ rhs: U) -> Bool where
> T : SequenceType,
> U : SequenceType,
> T.Generator.Element: Equatable,
> T.Generator.Element == U.Generator.Element
> {}
I'd still keep the generic arguments listed there in the brackets if only for
the following reasons:
1. The new names get introduced (in `<...>`) before their first use. So if you
happened to name one of them `String`, it would be clear that you didn't mean
`Swift.String`.
2. It's been sometimes wished that you could explicitly specify which
specialisation you want to use, e.g. when passing a function into a handler
(e.g. `let operation = anyCommonElements<[Int], [Int]>(_:_:)`).
3. How would you otherwise mention a generic type if there were no constraints
for it? I think the suggested form:
extension Array<T> {
// no constraints needed (not for T above, not for U below)
func map<U>(transform: T -> U) -> Array<U> { ... }
}
reads better than this:
extension Array<T> {
// Wait what, where did U come from?
func map(transform: T -> U) -> Array<U> { ... }
}
— Pyry_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution