[swift-evolution] [Discussion] Removing tuple labels from the type signature

David Hart david at hartbit.com
Thu Feb 4 03:10:09 CST 2016


Before I start working on a proposal, I’d like to understand the problem in detail. Can someone help me understand why parts of the language treats tuple labels as type and other not?

let a: (lhs: Int, rhs: Int) = (4, 5) // works
(4,5).dynamicType == (lhs: 2, rhs: 6).dynamicType // true

But:

[(lhs: 3, rhs: 5)] == [(1,2)]
// Binary operator ‘==‘ cannot be applied to operands of type ‘[(las: Int, rhs: Int)]’ and ‘[(Int, Int)]’
[(lhs: 3, rhs: 5)].dynamicType == [(1,2)].dynamicType
// Binary operator ‘==‘ cannot be applied to operands of type ‘Array<(las: Int, rhs: Int)>.Type’ and ‘Array<(Int, Int)>'

And:

struct Foo<T> {
	let bar: T
}

var foo1 = Foo(bar: (4, 5))
var foo2 = Foo(bar: (lhs: 4, rhs: 5))
foo1 = foo2
// Cannot assign value of type ‘Foo<(las: Int, res: Int)>’ to type ‘Foo<(Int, Int)>’

But:

foo1.dynamicType == foo2.dynamicType // true

So it seems that in parts of the language, they are treated with the same type, but not in generics.

Any input?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160204/76ff7cca/attachment.html>


More information about the swift-evolution mailing list