<div dir="ltr">Thank you. Overlooked that in the Swift 3 release notes.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Nov 11, 2016 at 3:43 PM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><blockquote type="cite"><span class=""><div>On Nov 11, 2016, at 11:54 AM, Muhammad Tahir Vali via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br class="m_-4113213712941228845Apple-interchange-newline"></span><span class=""><div><div dir="ltr">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><div><br></div><div>ex. </div><div><div style="margin:0px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,34,117)">typealias</span><span style="font-variant-ligatures:no-common-ligatures"> Name = (first: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">String</span><span style="font-variant-ligatures:no-common-ligatures">!, middle: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">String</span><span style="font-variant-ligatures:no-common-ligatures">?, last: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">String</span><span style="font-variant-ligatures:no-common-ligatures">!)</span></div></div><div><span style="font-variant-ligatures:no-common-ligatures"><div><div style="margin:0px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,34,117)">typealias</span><span style="font-variant-ligatures:no-common-ligatures"> Name = (first: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">String</span><span style="font-variant-ligatures:no-common-ligatures">!, middle: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">String</span><span style="font-variant-ligatures:no-common-ligatures">?, last: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">String</span><span style="font-variant-ligatures:no-common-ligatures">!)!</span></div><div style="margin:0px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures"><span style="color:rgb(195,34,117)">var</span> name : (</span><span style="font-variant-ligatures:no-common-ligatures">first: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">String</span><span style="font-variant-ligatures:no-common-ligatures">!, middle: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">String</span><span style="font-variant-ligatures:no-common-ligatures">?, last: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">String</span><span style="font-variant-ligatures:no-common-ligatures">!</span>)</div></div><div><span style="font-variant-ligatures:no-common-ligatures"><span style="font-family:menlo;font-variant-ligatures:no-common-ligatures"><font color="#c32275">var </font>name : (first: </span><span style="font-family:menlo;font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">String</span><span style="font-family:menlo;font-variant-ligatures:no-common-ligatures">!, middle: </span><span style="font-family:menlo;font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">String</span><span style="font-family:menlo;font-variant-ligatures:no-common-ligatures">?, last: </span><span style="font-family:menlo;font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">String</span><span style="font-family:menlo;font-variant-ligatures:no-common-ligatures">!)!</span><br></span></div><div><span style="font-variant-ligatures:no-common-ligatures"><span style="font-family:menlo;font-variant-ligatures:no-common-ligatures"><br></span></span></div><div><span style="font-variant-ligatures:no-common-ligatures">error from all 4 examples above:</span></div><div><span style="font-variant-ligatures:no-common-ligatures">Implicitly unwrapped optionals are only allowed at top level and as function results</span></div></span></div></div></div></div></span></blockquote><div><br></div>This is intentionally-designed behavior. Preventing IUO at arbitrary locations was SE-0054:</div><div> <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0054-abolish-iuo.md" target="_blank">https://github.com/apple/<wbr>swift-evolution/blob/master/<wbr>proposals/0054-abolish-iuo.md</a></div><div><br></div><div><span class=""><blockquote type="cite"><div><div dir="ltr"><div><div><span style="font-variant-ligatures:no-common-ligatures"><div><span style="font-variant-ligatures:no-common-ligatures">I also noticed that I can modify tuples using functions ONLY if I use <b>inout</b>. </span></div><div><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div><span style="font-variant-ligatures:no-common-ligatures"><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,34,117)">func</span><span style="font-variant-ligatures:no-common-ligatures"> name(Person : </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,34,117)">inout</span><span style="font-variant-ligatures:no-common-ligatures"> (first: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">String</span><span style="font-variant-ligatures:no-common-ligatures">?, middle: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">String</span><span style="font-variant-ligatures:no-common-ligatures">?, last: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">String</span><span style="font-variant-ligatures:no-common-ligatures">?)) {</span></div><div style="margin:0px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures"> Person.first = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(201,27,19)">"John"</span></div><div style="margin:0px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures"> Person.last = </span><span style="color:rgb(201,27,19)">"Doe"</span></div><div style="margin:0px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures">}</span></div><div style="margin:0px;line-height:normal;font-family:menlo"><br></div><div style="margin:0px;line-height:normal;font-family:menlo">OR </div><div style="margin:0px;line-height:normal;font-family:menlo"><br></div><div style="margin:0px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,34,117)">func</span><span style="font-variant-ligatures:no-common-ligatures"> name(Person : </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,34,117)">inout</span><span style="font-variant-ligatures:no-common-ligatures"> Name</span><span style="font-variant-ligatures:no-common-ligatures">) {</span></div><div style="margin:0px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures"> Person.first = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(201,27,19)">"John"</span></div><div style="margin:0px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures"> Person.last = </span><span style="color:rgb(201,27,19)">"Doe"</span></div><p style="margin:0px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures"></span></p><div style="margin:0px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures">}</span></div><div><br></div><div>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></div></blockquote><div><br></div></span>We used to allow "var" parameters, but they were removed in SE-0003:</div><div> <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0003-remove-var-parameters.md" target="_blank">https://github.com/apple/<wbr>swift-evolution/blob/master/<wbr>proposals/0003-remove-var-<wbr>parameters.md</a></div><div><br></div><div>Tuples are values like any other; I don't know why they would warrant a special exception to that rule.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>John.</div></font></span></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Best Regards,<div><br></div><div>Muhammad T. Vali</div></div></div>
</div>