<div dir="ltr"><div class="markdown-here-wrapper" style=""><p style="margin:0px 0px 1.2em!important">Hi Erica, thanks for restarting the discussion—I hope that it will be considered on topic for stage 2.</p>
<p style="margin:0px 0px 1.2em!important">I agree that the part with preventing <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">let .case(existingVar, newVar)</code> should be moved out of the proposal, because these issues are orthogonal. So the options with <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">~=</code> and <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">:=</code> will differ only in that the former overloads an existing custom operator.</p>
<p style="margin:0px 0px 1.2em!important">I prefer the version with keywords instead of operators, because overloading any custom operator can be confusing.</p>
<p style="margin:0px 0px 1.2em!important">I think that pattern should be on the right, because that’s the order of computation: first the expression, then pattern matching. That’s also how <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">switch</code> looks: first expression, then patterns.</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-comment" style="color:rgb(153,153,136);font-style:italic">// That's what current if-case looks like. Counterintuitive!</span>
<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">do</span> {
<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">case</span> .success(<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">let</span> value): …
<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">case</span> .failure(<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">let</span> value): …
} <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">switch</span> computeResult(foo(frobnicate), bar)
</code></pre>
<p style="margin:0px 0px 1.2em!important">Examples with <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">matches</code> and <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">is</code>, for extra brevity:</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-keyword" style="color:rgb(51,51,51);font-weight:bold">if</span> computeResult(foo(frobnicate), bar) matches .success(<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">let</span> value) { … }
<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">if</span> computeResult(foo(frobnicate), bar) <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">is</span> .success(<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">let</span> value) { … }
</code></pre>
<p style="margin:0px 0px 1.2em!important">I also considered using <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">-></code>. It would never be ambiguous in this context, but keywords still look better IMO:</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-keyword" style="color:rgb(51,51,51);font-weight:bold">if</span> computeResult(foo(frobnicate), bar) -> .success(<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">let</span> value) { … }
</code></pre>
<div title="MDH:PGRpdiBjbGFzcz0iZ21haWxfZXh0cmEiPkhpIEVyaWNhLCB0aGFua3MgZm9yIHJlc3RhcnRpbmcg
dGhlIGRpc2N1c3Npb24tLUkgaG9wZSB0aGF0IGl0IHdpbGwgYmUgY29uc2lkZXJlZCBvbiB0b3Bp
YyBmb3Igc3RhZ2UgMi48L2Rpdj48ZGl2IGNsYXNzPSJnbWFpbF9leHRyYSI+PGJyPjwvZGl2Pjxk
aXYgY2xhc3M9ImdtYWlsX2V4dHJhIj5JIGFncmVlIHRoYXQgd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