<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="">(Comments inline)<br class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Saagar Jha<br class=""><br class=""><br class=""></div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On Jul 20, 2016, at 16:47, Saagar Jha <<a href="mailto:saagarjha28@gmail.com" class="">saagarjha28@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br class=""><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Wed, Jul 20, 2016 at 12:52 PM Chris Lattner <<a href="mailto:clattner@apple.com" class="">clattner@apple.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">On Jul 19, 2016, at 3:46 PM, Saagar Jha <<a href="mailto:saagarjha28@gmail.com" target="_blank" class="">saagarjha28@gmail.com</a>> wrote:<br class=""></div><div style="word-wrap:break-word" class=""><div class=""><blockquote type="cite" class=""><br class=""><div class=""><div style="word-wrap:break-word" class="">I have updated the proposal <a href="https://gist.github.com/saagarjha/f33fecd4576f40133b6469da942ef453" target="_blank" class="">here</a>. Since this is a potentially a source breaking change, I’d like this to be considered for Swift 3; unless anyone has any issues with it, I’m going to push this to swift-evolution.</div></div></blockquote><div class=""><br class=""></div></div></div></blockquote></div></div></blockquote><div><br class=""></div><div>I know you don’t really want to discuss it, but since I don’t quite get what you mean, I was wondering if you could clarify a bit more <i class="">why</i> this proposal is inappropriate.</div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><div class="">Some comments:</div><div class="">- The syntax proposed would be *completely* unlike anything in Swift, and is semantically changing things unrelated to the type.</div></div></div></blockquote></div></div></blockquote><div><br class=""></div><div>There is no new syntax proposed; it is simply a restriction on the current syntax of using IUOs in functions, which I feel encourages unsafe behavior. The “syntax change” is no more than changing something like this:</div><div><br class=""></div><div><pre style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 16px; padding: 16px; line-height: 1.45; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: normal; color: rgb(51, 51, 51);" class=""><code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; background-color: transparent; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal; border: 0px; display: inline; line-height: inherit; word-wrap: normal;" class="">func triple(forceUnwrapping aNumber: Int!) -> Int? {
guard aNumber != nil else {
return nil
}
return aNumber * 3
}
</code></pre><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51);" class=""><font face="SFUIText-Regular" class="">to</font></p><pre style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; padding: 16px; line-height: 1.45; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: normal; color: rgb(51, 51, 51); margin-bottom: 0px !important;" class=""><code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; background-color: transparent; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal; border: 0px; display: inline; line-height: inherit; word-wrap: normal;" class="">func triple(withoutUnwrapping aNumber: Int?) -> Int? {
guard let aNumber = aNumber else { // simply transform the check
return nil
}
return aNumber * 3
}</code></pre><div class=""><br class=""></div></div>There’s not much of a difference, except that at the it makes it easier to see that nil is properly handled at the call site.</div><div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><div class="">- This proposal doesn’t work, and overly punishes IUOs.</div></div></div></blockquote></div></div></blockquote><div><br class=""></div><div>My goal is not to “punish” IUOs. I recognize that IUOs have valid uses, for example during initialization–and I want to leave this alone since this is the purpose of IUOs. My issue is with IUOs being “used as Optionals” in that they are allowed to have a nil value and checked for it (or not, with disastrous results). I’ve yet to see a function with an IUO parameter that couldn’t be rewritten to be clearer and more safe with a plain Optional parameter. Is there anything I’ve overlooked?</div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><div class=""><br class=""></div><div class="">I recommend that we do not discuss this proposal, as it would not be a good use of community time. Beyond the unworkability of this specific proposal, in my personal opinion, there is nothing wrong with the T! syntax. Making it significantly more verbose would be a very *bad* thing for the intended use cases.</div></div></div></blockquote></div></div></blockquote><div><br class=""></div><div>As before, this proposal is <b class="">not</b> an attack on IUOs and the T! syntax, it’s against their misuse as function parameters and return values. A significant increase in verbosity is obviously undesirable, but I don’t see how this proposal will cause an increase in length.</div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><div class=""><br class=""></div><div class="">-Chris</div></div></div><div style="word-wrap:break-word" class=""><div class=""><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap:break-word" class=""><div class=""><br class=""><div class="">
<div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word" class="">Saagar Jha<br class=""><br class=""><br class=""></div>
</div>
<br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jul 5, 2016, at 13:30, Saagar Jha <<a href="mailto:saagarjha28@gmail.com" target="_blank" class="">saagarjha28@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class="">Gave me a chuckle, but yeah, basically.</div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Tue, Jul 5, 2016 at 12:54 PM William Jon Shipley <<a href="mailto:wjs@delicious-monster.com" target="_blank" class="">wjs@delicious-monster.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">On Jun 30, 2016, at 9:22 AM, Saagar Jha via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:<br class=""><div class=""><blockquote type="cite" class=""><span style="font-family:HelveticaNeue;float:none;display:inline!important" class="">When I see an IUO property, I consider it a sort of “contract”–it’s basically saying something like “I can’t set this to a valid value right now, but by the time you use it I promise that it’s non </span><code class="">nil</code><span style="font-family:HelveticaNeue;float:none;display:inline!important" class="">”</span></blockquote></div><br class=""></div><div style="word-wrap:break-word" class=""><div class="">You might say that an IUO is sort of an IOU?</div></div><div style="word-wrap:break-word" class=""><div class=""><br class=""></div><div class="">-W</div></div></blockquote></div><div dir="ltr" class="">-- <br class=""></div><div data-smartmail="gmail_signature" class=""><div dir="ltr" class="">-Saagar Jha</div></div></div></blockquote></div><br class=""></div></div></div></blockquote></div></div></blockquote></div></div></blockquote></div><br class=""></body></html>