<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=""><div><blockquote type="cite" class=""><div class="">On Nov 11, 2016, at 11:54 AM, 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>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" class="">https://github.com/apple/swift-evolution/blob/master/proposals/0054-abolish-iuo.md</a></div><div><br class=""></div><div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><div class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><div class=""><span style="font-variant-ligatures:no-common-ligatures" class="">I also noticed that I can modify tuples using functions ONLY if I use <b class="">inout</b>. </span></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></div></blockquote><div><br class=""></div>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" class="">https://github.com/apple/swift-evolution/blob/master/proposals/0003-remove-var-parameters.md</a></div><div><br class=""></div><div>Tuples are values like any other; I don't know why they would warrant a special exception to that rule.</div><div><br class=""></div><div>John.</div></body></html>