<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">+1</div><div class=""><br class=""></div><div class="">Although I think almost all examples are bugs:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">// As expected</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> a: (lhs: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span>, rhs: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span>) = (<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">4</span>, <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">5</span>) <span style="font-variant-ligatures: no-common-ligatures; color: #008400" class="">// works</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">(<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">4</span>,<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">5</span>).<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">dynamicType</span> == (lhs: <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">2</span>, rhs: <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">6</span>).<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">dynamicType</span> <span style="font-variant-ligatures: no-common-ligatures; color: #008400" class="">// true</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> arr1 = [(lhs: <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">3</span>, rhs: <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">5</span>)]</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> arr2 = [(<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span>,<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">2</span>)]</div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">// == can only be used for equatable element types. Right now Tuples are not equatable</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">arr1 == arr2</div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">// doesn't work: I assume it is a bug see below</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">[(lhs: <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">3</span>, rhs: <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">5</span>)].<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">dynamicType</span> == [(<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span>,<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">2</span>)].<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">dynamicType</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> type = [(lhs: <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">3</span>, rhs: <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">5</span>)].<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">dynamicType</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> type2 = [(<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span>,<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">2</span>)].<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">dynamicType</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">type == type2 <span style="font-variant-ligatures: no-common-ligatures; color: #008400" class="">// works!</span><span class="Apple-tab-span" style="white-space: pre;">        </span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class="webkit-block-placeholder"></p><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">struct</span> Foo<T> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> bar: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> foo1 = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Foo</span>(bar: (<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">4</span>, <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">5</span>))</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> foo2 = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Foo</span>(bar: (lhs: <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">4</span>, rhs: <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">5</span>))</div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">// still an error</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">foo1 = foo2</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">// Cannot assign value of type ‘Foo<(lhs: Int, rhs: Int)>’ to type ‘Foo<(Int, Int)>’</div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">// As expected</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">foo1.</span>dynamicType<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> == foo2.</span>dynamicType<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #008400" class="">// true</span></div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures; color: #008400" class=""><br class=""></span></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">As summary: Tuples are not equatable , dynamic types of Array literals are buggy , weird generic behavior.</div><div class=""><br class=""></div><div class="">You should file a bug/radar.</div><div class=""><br class=""></div><div class="">Best regards</div><div class="">- Maximilian</div><br class=""><div><blockquote type="cite" class=""><div class="">Am 04.02.2016 um 10:10 schrieb David Hart via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>>:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">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?<div class=""><div class=""><br class=""></div><div class=""><font face="Menlo" class="">let a: (lhs: Int, rhs: Int) = (4, 5) // works</font></div><div class=""><font face="Menlo" class="">(4,5).dynamicType == (lhs: 2, rhs: 6).dynamicType // true</font></div><div class=""><br class=""></div><div class="">But:</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">[(lhs: 3, rhs: 5)] == [(1,2)]</font></div><div class=""><font face="Menlo" class="">// Binary operator ‘==‘ cannot be applied to operands of type ‘[(las: Int, rhs: Int)]’ and ‘[(Int, Int)]’</font></div><div class=""><font face="Menlo" class="">[(lhs: 3, rhs: 5)].dynamicType == [(1,2)].dynamicType</font></div><div class=""><font face="Menlo" class="">// Binary operator ‘==‘ cannot be applied to operands of type ‘Array<(las: Int, rhs: Int)>.Type’ and ‘Array<(Int, Int)>'</font></div><div class=""><br class=""></div><div class="">And:</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">struct Foo<T> {<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>let bar: T<br class="">}<br class=""><br class="">var foo1 = Foo(bar: (4, 5))<br class="">var foo2 = Foo(bar: (lhs: 4, rhs: 5))<br class="">foo1 = foo2</font></div><div class=""><font face="Menlo" class="">// Cannot assign value of type ‘Foo<(las: Int, res: Int)>’ to type ‘Foo<(Int, Int)>’</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">But:</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">foo1.dynamicType == foo2.dynamicType // true</font></div><div class=""><br class=""></div><div class="">So it seems that in parts of the language, they are treated with the same type, but not in generics.</div></div><div class=""><br class=""></div><div class="">Any input?</div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>