<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Having the migrator add a ! will result in consistent behaviour with current code.</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">The only issue here is that by adding in !, it somehow might suggest to someone reading the code "hey, the writer though about this and is sure it's safe" but really, they should have been checking it anyway currently, and at least someone can *see* their error...</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">- Rod</div><div><br>On 7 Jan 2016, at 8:33 AM, Jacob Bandes-Storch <<a href="mailto:jtbandes@gmail.com">jtbandes@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">I'd be in favor of that, although I imagine it would be very challenging to change the nullability of the return type without wreaking havoc on thousands of lines of legacy code. Having the migrator add "!" wouldn't be all that great.<div><br></div><div>I think there's also precedent in the stdlib for there to be "unsafe" variants of these things which skip the bounds-check if you really care for performance reasons: like unsafeUnwrap(), you could have an unsafeRemoveFirst().</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div>Jacob Bandes-Storch<br></div></div></div></div>
<br><div class="gmail_quote">On Wed, Jan 6, 2016 at 1:30 PM, Rod Brown <span dir="ltr"><<a href="mailto:rodney.brown6@icloud.com" target="_blank">rodney.brown6@icloud.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>You make a fair point. I would agree the risk is far higher, to be honest. At least returning an optional forces you to do something about the fact it might not have happened, even if it's only to use the ! force unwrapper.</div><div><br></div><div>Also of note, as of OS X 10.7, removeLastObject for example on NSMutableArray no longer creates a range exception, and instead simply returns nil.</div><div><br></div><div>Perhaps we need to treat these methods as conveniences, and as such subscripting still gets range exceptions, but removeFirst, removeLast etc should get optional return types and no fail if it's empty?</div></div></blockquote></div></div></div>
</div></blockquote></body></html>