<div dir="ltr"><div class="markdown-here-wrapper" style=""><p style="margin:0px 0px 1.2em!important">I don’t see how you can have parallelism without having some horrible potential bugs.<br>Imagine the following situation:</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-java" 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">public</span> <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">static</span> AtomicBoolean bl = <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">new</span> AtomicBoolean(<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">true</span>);
<span class="hljs-function"><span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">public</span> <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">static</span> <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">void</span> <span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold">sideEffect</span><span class="hljs-params">()</span> </span>{ bl.set(<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">false</span>); <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">return</span> <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">true</span>; }
Integer i = <span class="hljs-number" style="color:rgb(0,128,128)">0</span>;
<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">switch</span> (i) {
    <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">case</span> Integer i when bl.get() -> ...
    <span class="hljs-function"><span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">case</span> Integer i when <span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold">sideEffect</span><span class="hljs-params">()</span> -> ...
    ...
}</span>
</code></pre>
<p style="margin:0px 0px 1.2em!important">In this example we can have:</p>
<ul style="margin:1.2em 0px;padding-left:2em">
<li style="margin:0.5em 0px">Enter case 1 with correct state</li>
<li style="margin:0.5em 0px">Enter case 2 with correct state</li>
<li style="margin:0.5em 0px">Enter case 1 with wrong state</li>
</ul>
<p style="margin:0px 0px 1.2em!important">Using move variables we can create a (albeit a bit pathological) example with any number of cases that all can be entered with a wrong state (apart from maybe the default branch).</p>
<p style="margin:0px 0px 1.2em!important">Also, it can be dangerous when the <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">when</code> clause is expensive. Maybe it is possible to calculate the non-<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">when</code> clause in parallel fashion, but I don’t know if it worth the effort</p>
<div title="MDH:SSBkb24ndCBzZWUgaG93IHlvdSBjYW4gaGF2ZSBwYXJhbGxlbGlzbSB3aXRob3V0IGhhdmluZyBz
b21lIGhvcnJpYmxlIHBvdGVudGlhbCBidWdzLjxicj5JbWFnaW5lIHRoZSBmb2xsb3dpbmcgc2l0
dWF0aW9uOjxkaXY+PGJyPjwvZGl2PjxkaXY+YGBgamF2YTwvZGl2PjxkaXY+cHVibGljIHN0YXRp
YyBBdG9taWNCb29sZWFuIGJsID0gbmV3IEF0b21pY0Jvb2xlYW4odHJ1ZSk7PC9kaXY+PGRpdj5w
dWJsaWMgc3RhdGljIHZvaWQgc2lkZUVmZmVjdCgpIHsgYmwuc2V0KGZhbHNlKTsgcmV0dXJuIHRy
dWU7IH08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IGlzIGV4cGVuc2l2ZS4gTWF5YmUgaXQgaXMgcG9zc2li
bGUgdG8gY2FsY3VsYXRlIHRoZSBub24tYHdoZW5gIGNsYXVzZSBpbiBwYXJhbGxlbCBmYXNoaW9u
LCBidXQgSSBkb24ndCBrbm93IGlmIGl0IHdvcnRoIHRoZSBlZmZvcnQ8L2Rpdj4=" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0"></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Apr 22, 2023 at 4:16 AM David Alayachew <<a href="mailto:davidalayachew@gmail.com">davidalayachew@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:monospace" class="gmail_default"><br>Hello Steve,<br><br>Thank you for your response!<br><br>> It feels to me that Boolean short circuiting in<br>> conditionals and statement ordering in switches would<br>> both preclude parallel evaluation of conditions<br><br>I'm actually expecting you to be correct here.<br><br>The reason I originally asked this question is because I have been doing a lot of study into when and where parallelism starts to become useful when coding in Java. Long story short, it improves performance way earlier than I ever expected. And not only that, Java actually does a whole bunch of parallelism itself under the hood too. Compilation, class loading, etc. I thought I knew the threshold at which parallelism would start being useful, but apparently it's way earlier than I thought.<br><br>> absent some infective constery to wave away side effects<br><br>Google does not seem to be much help. What does this quote mean?<br><br>> In any event - do you envisage any benefit from parallel<br>> evaluation? On such scales would runtime cost not be<br>> dominated by dispatch and synchronisation?<br><br>Well at this point, I have no idea. I don't really know where the ceiling is anymore, so I am testing out (what I think is) a complete long shot, just to give myself an upper bound here. Worst case is they say no, which is what I am expecting.</div><div style="font-family:monospace" class="gmail_default"><br></div><div style="font-family:monospace" class="gmail_default">Thank you for your time!</div><div style="font-family:monospace" class="gmail_default">David Alayachew</div><br></div>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr">Holo The Wise Wolf Of Yoitsu</div></div>