<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 28, 2016, at 20:00, Chris Lattner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</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=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jan 28, 2016, at 7:57 PM, Chris Lattner &lt;<a href="mailto:clattner@apple.com" class="">clattner@apple.com</a>&gt; wrote:</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=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jan 28, 2016, at 5:07 PM, Erica Sadun via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</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=""><div class="">I find&nbsp;</div><div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class="">let values: (4 x Int) = (1, 2, 3, 4)</font></div></div><div class=""><br class=""></div><div class="">to be adequately cromulent. I believe this approach to be:</div><div class=""><br class=""></div><div class="">* Readable, even to someone unfamiliar with the syntax</div><div class="">* The parens before the assignment suggest something to do with tuples, and the numbers match the arity after the assignment</div><div class="">* The type is preserved in-place</div><div class="">* It's compact, elegant, simple</div></div></div></blockquote><div class=""><br class=""></div><div class="">+1. &nbsp;I like this syntax too, and with Joe’s other proposed extensions, it would all fit together nicely. &nbsp;Anyone interested in writing up a proposal?</div></div></div></div></blockquote><br class=""></div><div class="">One other tweak worth considering: instead of subscript being defined on a tuple as returning a common type, a more modest proposal would be that subscript is defined on tuples that:</div><div class=""><br class=""></div><div class="">a) have no element labels.</div><div class="">b) all have the same element type.</div><div class=""><br class=""></div><div class="">This would solve the fixed size array use-case, be much easier to implement, and not have surprising performance issues promoting things to Any. &nbsp;It is also consistent with the fact that we don’t infer the type of [Int(), Float()] to [Any].</div><div class=""><br class=""></div><div class="">-Chris</div></div></div></blockquote></div><div class=""><br class=""></div><div class="">(Sorry to go so far back… I started replying to this on probably the 29th and somehow forgot about it.)</div><br class=""><div class=""><div class=""><div class="">Out of curiosity, why would the subscript of non-homogeneous tuple have to return an "Any”? If we declare this:</div><div class=""><span style="color: rgb(211, 54, 130); font-family: 'Fira Mono';" class="">let</span><font color="#93a1a1" face="Fira Mono" class="">&nbsp;grohl = (</font><span style="color: rgb(108, 113, 196); font-family: 'Fira Mono';" class="">0</span><font color="#93a1a1" face="Fira Mono" class="">,&nbsp;</font><font color="#dc322f" face="Fira Mono" class="">“foo</font><font face="Fira Mono" class=""><font color="#dc322f" class="">”</font><font color="#93a1a1" class="">,&nbsp;</font></font><font color="#dc322f" face="Fira Mono" class="">“fighters</font><font face="Fira Mono" class=""><font color="#dc322f" class="">”</font><font color="#93a1a1" class="">,&nbsp;</font></font><span style="color: rgb(108, 113, 196); font-family: 'Fira Mono';" class="">0.0</span><font color="#93a1a1" face="Fira Mono" class="">)</font></div><div class=""><div style="margin: 0px; line-height: normal;" class=""><div style="margin: 0px; line-height: normal;" class=""><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">Why couldn’t subscript (and $0 in map, for that matter) return a type that’s the “intersection” of Int, String, and Double?</div><div style="margin: 0px; line-height: normal;" class=""><span style="color: rgb(203, 75, 22); font-family: 'Fira Mono';" class="">// compiler expands this to (grohl.0.hashValue,&nbsp;</span><span style="color: rgb(203, 75, 22); font-family: 'Fira Mono';" class="">grohl.1</span><font color="#cb4b16" face="Fira Mono" class="">.hashValue,&nbsp;grohl.2.hashValue,&nbsp;grohl.3.hashValue)</font></div><div style="margin: 0px; line-height: normal;" class=""><span style="color: rgb(211, 54, 130); font-family: 'Fira Mono';" class="">let</span><font color="#93a1a1" face="Fira Mono" class="">&nbsp;thatsJustCrazyTalk&nbsp;=&nbsp;grohl.</font><span style="color: rgb(39, 139, 210); font-family: 'Fira Mono';" class="">map</span><font color="#93a1a1" face="Fira Mono" class="">&nbsp;{$0.</font><span style="color: rgb(39, 139, 210); font-family: 'Fira Mono';" class="">hashValue</span><font color="#93a1a1" face="Fira Mono" class="">}&nbsp;</font><span style="color: rgb(203, 75, 22); font-family: 'Fira Mono';" class="">// no error because Int, String, and Double all have a hashValue property…</span></div></div><div style="margin: 0px; line-height: normal;" class=""><div class=""><div style="margin: 0px; line-height: normal;" class=""><br class=""></div></div></div></div></div></div><div class="">It seems to me that figuring out what’s legal for $0 wouldn’t be that hard… I mean, at the risk of publicizing my ignorance regarding the compiler’s internal workings, in my head, at least, the compiler maintains a set of valid functions/properties for each type, and $0’s set would literally just be the intersection of the sets associated with the types in the tuple.</div><div class=""><br class=""></div><div class="">Is it way more complicated than that? (One of these days I’m going to figure out how LLVM works so that I won’t have ask questions like that.)</div><div class=""><br class=""></div><div class=""><div class="">- Dave Sweeris</div></div><div class=""><br class=""></div><div><blockquote type="cite" class=""></blockquote></div></div></body></html>