<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="">Just spit-balling here, but couldn’t you do this with a generic extension on Optional?<div class=""><br class=""></div><div class=""><font face="Menlo" class=""><blockquote type="cite" class="">extension Optional {<br class=""> func returnsNil(errorCode: Int) -> Wrapped? {<br class=""> logError(errorCode)<br class=""> return nil<br class=""> }<br class="">}</blockquote></font></div><div class=""><br class=""></div><div class=""><br class=""><div class="">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; " class=""><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; " class=""><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; " class=""><span class="Apple-style-span" style="border-collapse: separate; line-height: normal; border-spacing: 0px;"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; " class=""><div class="">Jeff Kelley</div><div class=""><br class=""></div><div class=""><a href="mailto:SlaunchaMan@gmail.com" class="">SlaunchaMan@gmail.com</a> | <a href="https://twitter.com/SlaunchaMan" class="">@SlaunchaMan</a> | <a href="http://jeffkelley.org" class="">jeffkelley.org</a></div></div></span></div></div></div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On Jan 3, 2016, at 10:43 PM, Andrew Duncan 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 class="">It should be possible to declare a function that returns only nil, and have its return type be substitutable for any function that returns and Optional. This is something like having a bottom type but not really. What I mean is:<br class=""><br class="">func returnsNil(errCode:Int) -> nil {<br class=""> logError(errCode) // A side-effect. Not FP, sosumi.<br class=""> return nil<br class="">}<br class=""><br class="">func returnAOptional() -> A? {<br class=""> // Bla bla. We discover an error so we decide to bail and return nil.<br class=""> return returnsNil(errCode) // Would be legal.<br class="">}<br class="">func returnsBOptional() -> B? {<br class=""> // Bla bla. We discover an error so we decide to bail and return nil.<br class=""> return returnsNil(errCode) // Would also be legal.<br class="">}<br class=""><br class="">I seek a return type that conforms to any Optional -- I think that implies it *must* (or correct me here) be nil.<br class=""><br class="">Now perhaps this is already possible with wizardry from the Next Level. (There always is one.)</div></div></blockquote></div></div></body></html>