<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><blockquote type="cite" class="">On Dec 22, 2015, at 12:03 PM, Chris Lattner <<a href="mailto:clattner@apple.com" class="">clattner@apple.com</a>> wrote:<br class=""><br class=""><blockquote type="cite" class="">On Dec 22, 2015, at 9:44 AM, David Owens II via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class=""><blockquote type="cite" class="">On Dec 22, 2015, at 9:30 AM, Paul Cantrell via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class="">Hmm, I wonder if #1 or #4 suggest any language changes to propose for this list.<br class=""></blockquote><br class="">Tangential to the topic at hand, but default values in tuples is something I’ve wanted for a while. Comparing optionals in a case statement would also be nice.<br class=""></blockquote><br class="">If you dig through history, you’ll find that we had them at one point (perhaps even in the swift 1.x timeframe), and we even had varargs tuples. We removed both of them because they were infrequently used and adding a tremendous amount of complexity to the compiler (and were very buggy as a result).<br class=""></blockquote><div class=""><br class=""></div>If you squint a little, tuples are just anonymous structs with limited features. If you squint.<div class=""><br class=""><div class="">One of my favorite features of Swift is how (at least at the semantic level) it has no primitive types. Int is a struct! Brilliant! I’ve wondered on and off (even before this list) if perhaps the language could eliminate another fundamental type by making tuples just be sugar for structs.</div><div class=""><br class=""></div><div class="">What would that look like? I am thinking out loud here…</div><div class=""><br class=""></div><div class="">• Every tuple is secretly just an instance of an anonymous struct, much as optionals are secretly just enums.</div>• Under the covers, functions all take a single struct argument and return a single struct.<div class="">• Pattern matching can destructure structs. (Hmm, trouble here. Property ordering in structs is suddenly significant in the API, not just the ABI.)</div><div class="">• The tuple syntax infers the type of the struct to be created, and can match both named and anonymous structs … which it does by matching initializers, whose arguments are a tuple, so … turtles all the way down? More trouble.</div><div class="">• The existing unwrapping of single-elem tuples is preserved, i.e. `let a: (Int,Int) = (((((3))),3))` still works.</div><br class=""><div class="">All of this would mean that this:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">enum</span> Doodad</div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> {</div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">case</span> Doo</div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">case</span> Dad(name: String)</div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> }</div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; min-height: 12px;" class="">…is equivalent to this (except for the introduction of the new “DadInfo” identifier for what was previously anonymous):</div><div class=""><span style="font-family: 'Helvetica Neue'; font-size: 13px;" class=""><br class=""></span></div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">struct</span> DadInfo</div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> {</div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">var</span> name: <span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">String</span></div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> }</div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">enum</span> Doodad</div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> {</div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">case</span> Doo</div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">case</span> Dad(DadInfo)</div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> }</div></div><div class=""><br class=""></div><div class="">…and thus this is a non-breaking change:</div><div class=""><br class=""></div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">struct</span> DadInfo</div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> {</div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">var</span> name: <span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">String</span></div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">var</span> punRating: <span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">JokeType</span> = .Terrible</div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> }</div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">enum</span> Doodad</div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> {</div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">case</span> Doo</div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">case</span> Dad(DadInfo)</div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> }</div><div class=""><br class=""></div><div class="">OK, so that’s an <i class="">awful</i> lot of squinting. It’s not clear that there’s an end game here that makes sense.</div><div class=""><br class=""></div><div class="">Cheers,</div><div class=""><br class=""></div><div class="">Paul</div><div class=""><br class=""></div></div></body></html>