<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></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 11 Nov 2016, at 19:54, Muhammad Tahir Vali via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Im curious to know the reasoning behind why implicit-wrapped optionals aren't allowed when creating tuples. Below is an example with type aliases and anonymous tuples.<div class=""><div class=""><br class=""></div><div class="">ex. </div><div class=""><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,34,117)" class="">typealias</span><span style="font-variant-ligatures:no-common-ligatures" class=""> Name = (first: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">!, middle: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">?, last: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">!)</span></div></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><div class=""><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,34,117)" class="">typealias</span><span style="font-variant-ligatures:no-common-ligatures" class=""> Name = (first: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">!, middle: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">?, last: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">!)!</span></div><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><span style="color:rgb(195,34,117)" class="">var</span> name : (</span><span style="font-variant-ligatures:no-common-ligatures" class="">first: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">!, middle: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">?, last: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">!</span>)</div></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><span style="font-family:menlo;font-variant-ligatures:no-common-ligatures" class=""><font color="#c32275" class="">var </font>name : (first: </span><span style="font-family:menlo;font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-family:menlo;font-variant-ligatures:no-common-ligatures" class="">!, middle: </span><span style="font-family:menlo;font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-family:menlo;font-variant-ligatures:no-common-ligatures" class="">?, last: </span><span style="font-family:menlo;font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-family:menlo;font-variant-ligatures:no-common-ligatures" class="">!)!</span><br class=""></span></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><span style="font-family:menlo;font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></span></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class="">error from all 4 examples above:</span></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class="">Implicitly unwrapped optionals are only allowed at top level and as function results</span></div></span></div></div></div></div></blockquote><div><br class=""></div><div>I think in general the direction is leaning towards getting rid of IUO's entirely if possible, as a lot of things that people use them for could be handled better in other ways; the only times I've ever used them is to get around issues with constructors (namely the requirement to initialise everything before other methods can be called), but that could be solved by detecting or marking methods that would be safe for that.</div><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class=""><div class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><div class="">I also noticed that I can modify tuples using functions ONLY if I use <b class="">inout</b>. </div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,34,117)" class="">func</span><span style="font-variant-ligatures:no-common-ligatures" class=""> name(Person : </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,34,117)" class="">inout</span><span style="font-variant-ligatures:no-common-ligatures" class=""> (first: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">?, middle: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">?, last: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">?)) {</span></div><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""> Person.first = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(201,27,19)" class="">"John"</span></div><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""> Person.last = </span><span style="color:rgb(201,27,19)" class="">"Doe"</span></div><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">}</span></div><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; font-family: menlo;" class="">OR </div><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,34,117)" class="">func</span><span style="font-variant-ligatures:no-common-ligatures" class=""> name(Person : </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,34,117)" class="">inout</span><span style="font-variant-ligatures:no-common-ligatures" class=""> Name</span><span style="font-variant-ligatures:no-common-ligatures" class="">) {</span></div><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""> Person.first = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(201,27,19)" class="">"John"</span></div><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""> Person.last = </span><span style="color:rgb(201,27,19)" class="">"Doe"</span></div><p style="margin:0px;line-height:normal;font-family:menlo" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""></span></p><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">}</span></div><div class=""><br class=""></div><div class="">This is because tuples are passed into functions as 'let' constants. Why not add the ability to modify a copy of the tuple inside the function ?</div></span></span></div></span></div></div></div></blockquote><br class=""></div><div>The ability to specify function arguments as mutable was removed to avoid confusion with inout as it wasn't completely obvious that with a var what you're modifying is a copy. However you can make a mutable copy with shadowing, like-so:</div><div><br class=""></div><div><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>func name(Person:(first:String?, middle:String?, last:String?) { var Person = Person // Person is now a mutable copy</font></div><div><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">                </span>Person.first = "John"</font></div><div><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">                </span>Person.last = "Doe"</font></div><div><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</font></div><div><br class=""></div><div>Obviously with the caveat that these changes don't exist outside of that scope, so unless you make use of them there that code will likely just get optimised away.</div></body></html>