<div dir="ltr"><div class="markdown-here-wrapper" style=""><p style="margin:0px 0px 1.2em!important">2016-11-09 0:12 GMT+03:00 Adrian Zubarev <<a href="mailto:adrian.zubarev@devandartist.com" target="_blank">adrian.zubarev@devandartist.com</a>>:</p>
<p style="margin:0px 0px 1.2em!important"></p><div class="markdown-here-exclude"><p></p><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div class="gmail-m_-4437323717037443433bloop_markdown"><p>Could you elaborate an implementation for one of these functions:</p></div></div></blockquote><p></p></div><p style="margin:0px 0px 1.2em!important"></p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code class="hljs language-swift" style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;overflow-x:auto;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,248)"><span class="hljs-func"><span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">func</span> == <span class="hljs-generics"><T></span><span class="hljs-params">(<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">left</span>: T?, <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">right</span>: Nil)</span> </span>{
<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">switch</span> <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">left</span> {
<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">case</span> .some(<span class="hljs-number" style="color:rgb(0,128,128)">_</span>): <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">return</span> <span class="hljs-built_in" style="color:rgb(0,134,179)">false</span>
<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">case</span> .<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">none</span>: <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">return</span> <span class="hljs-built_in" style="color:rgb(0,134,179)">true</span>
}
}
</code></pre>
<p style="margin:0px 0px 1.2em!important">The implementation is basically the same as of now, except that instead of <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">Nil</code>, there is <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">_OptionalNilComparisonType</code>.</p>
<p style="margin:0px 0px 1.2em!important">Main use case of <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">Nil</code> would essentially be partial specialization of functions.<br>See example with optional comparison: there exists a generic version that takes a proper <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">ExpressibleByNilLiteral</code> (in this case <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">Optional<T></code>), but we can apply simpler logic in case we see <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">nil</code>.</p>
<p style="margin:0px 0px 1.2em!important">Frankly speaking, I’m not sure myself this feature would find any use except for the mentioned optional comparison operators.<br>So I will probably stop pushing this forward.</p>
<div title="MDH:PGRpdiBjbGFzcz0iZ21haWxfZXh0cmEiPjxkaXYgY2xhc3M9ImdtYWlsX3F1b3RlIj4yMDE2LTEx
LTA5IDA6MTIgR01UKzAzOjAwIEFkcmlhbiBadWJhcmV2IDxzcGFuIGRpcj0ibHRyIj4mbHQ7PGEg
aHJlZj0ibWFpbHRvOmFkcmlhbi56dWJhcmV2QGRldmFuZGFydGlzdC5jb20iIHRhcmdldD0iX2Js
YW5rIj5hZHJpYW4uenViYXJldkBkZXZhbmRhcnRpc3QuY29tPC9hPiZndDs8L3NwYW4+Ojxicj48
YmxvY2txdW90ZSBjbGFzcz0iZ21haWxfcXVvdGUiIHN0eWxlPSJtYXJnaW46IDBweCAwcHggMHB4
IDAuOGV4OyBib3JkZXItbGVmdDogMXB4IHNvbGlkIHJnYigyMDQsIDIwNCwgMjA0KTsgcGFkZGlu
Zy1sZWZ0OiAxZXg7Ij48ZGl2IHN0eWxlPSJ3b3JkLXdyYXA6IGJyZWFrLXdvcmQ7Ij48ZGl2IGNs
YXNzPSJnbWFpbC1tXy00NDM3MzIzNzE3MDM3NDQzNDMzYmxvb3BfbWFya2Rvd24iPjxwPkNvdWxk
IHlvdSBlbGFib3JhdGUgYW4gaW1wbGVtZW50YXRpb24gZm9yIG9uZSBvZiB0aGVzZSBmdW5jdGlv
bnM6PC9wPjwvZGl2PjwvZGl2PjwvYmxvY2txdW90ZT48ZGl2PmBgYHN3aWZ0PGJyPjwvZGl2Pjxk
aXY+ZnVuYyA9PSAmbHQ7VCZndDsobGVmdDogVD8sIHJpZ2h0OiBOaWwpIHs8L2Rpdj48ZGl2PiZu
YnNwOyAmbmJzcDsgc3dpdGNoIGxlZnQgezwvZGl2PjxkaXY+Jm5ic3A7ICZuYnNwOyAmbmJzcDsg
Jm5ic3A7IGNhc2UgLnNvbWUoXyk6IHJldHVybiBmYW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