Thanks @Joe_Groff. I have a couple of follow up questions:
1
As far as I can understand, this must imply either:
- That every type
T
is a (single element unlabeled) tuple type.
or
- That there is no such thing as a single-element tuple type.
Which one is it? Or is there another possibility?
2
The following is an example from the generics manifesto, I've just added the foo()
method and ==
, so I guess this would be considered valid code once Swift has variadic generics:
extension<...Elements : Equatable> (Elements...) : Equatable { // extending the tuple type "(Elements...)" to be Equatable
func foo() { }
static func == (lhs: (Elements...), rhs: (Elements...)) -> Bool { details … }
}
Wouldn't this have to special case (Elements...) to not include the substitution T
(equivalent to (T)
)?
Perhaps this is what is meant by the following lines of the manifesto:
There are some natural bounds here: one would need to have actual structural types. One would not be able to extend every type:
extension T { // error: neither a structural nor a nominal type
}
?
If there is no special casing performed for this example, ie the substitution T
is included, then I guess every type that conforms to Equatable
(including eg Int
) would get the foo()
method (and a redundant conformance to Equatable
)?