<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&nbsp;Optional&nbsp;{<br class="">&nbsp; &nbsp;&nbsp;func&nbsp;returnsNil(errorCode:&nbsp;Int) -&gt;&nbsp;Wrapped? {<br class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;logError(errorCode)<br class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;nil<br class="">&nbsp; &nbsp;&nbsp;}<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>&nbsp;|&nbsp;<a href="https://twitter.com/SlaunchaMan" class="">@SlaunchaMan</a>&nbsp;|&nbsp;<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 &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; 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) -&gt; nil {<br class=""> &nbsp;&nbsp;&nbsp;logError(errCode) &nbsp;&nbsp;&nbsp;&nbsp;// A side-effect. Not FP, sosumi.<br class=""> &nbsp;&nbsp;&nbsp;return nil<br class="">}<br class=""><br class="">func returnAOptional() -&gt; A? {<br class=""> &nbsp;&nbsp;&nbsp;// Bla bla. We discover an error so we decide to bail and return nil.<br class=""> &nbsp;&nbsp;&nbsp;return returnsNil(errCode) // Would be legal.<br class="">}<br class="">func returnsBOptional() -&gt; B? {<br class=""> &nbsp;&nbsp;&nbsp;// Bla bla. We discover an error so we decide to bail and return nil.<br class=""> &nbsp;&nbsp;&nbsp;return returnsNil(errCode) &nbsp;// 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>