<div dir="ltr"><div class="markdown-here-wrapper" style=""><blockquote style="margin:1.2em 0px;border-left:4px solid rgb(221,221,221);padding:0px 1em;color:rgb(119,119,119);quotes:none">
<p style="margin:0px 0px 1.2em!important"> slam dunk argument for changing that API to use lambda expressions</p>
</blockquote>
<p style="margin:0px 0px 1.2em!important">I think you misunderstood me, I am not arguing that the API should change, I am saying that enforced try-with-resources is very relevant to almost all “structured-API”s, and there should be work on it moving forward.</p>
<p style="margin:0px 0px 1.2em!important">I wrote a simple <a href="https://github.com/Holo314/forceClosable">error-prone plugin</a> for enforced TwR as a PoC.</p>
<div title="MDH:Jmd0O8KgCgpzbGFtIGR1bmsgYXJndW1lbnQgZm9yIGNoYW5naW5nIHRoYXQgQVBJIHRvIHVzZSBs
YW1iZGEgZXhwcmVzc2lvbnM8YnI+PGJyPkkgdGhpbmsgeW91IG1pc3VuZGVyc3Rvb2QgbWUsIEkg
YW0gbm90IGFyZ3VpbmcgdGhhdCB0aGUgQVBJIHNob3VsZCBjaGFuZ2UsIEkgYW0gc2F5aW5nIHRo
YXQgZW5mb3JjZWQgdHJ5LXdpdGgtcmVzb3VyY2VzIGlzIHZlcnkgcmVsZXZhbnQgdG8gYWxtb3N0
IGFsbCAic3RydWN0dXJlZC1BUEkicywgYW5kIHRoZXJlIHNob3VsZCBiZSB3b3JrIG9uIGl0IG1v
dmluZyBmb3J3YXJkLjxkaXY+PGJyPjwvZGl2PjxkaXY+SSB3cm90ZSBhIHNpbXBsZSBbZXJyb3It
cHJvbmUgcGx1Z2luXShodHRwczovL2dpdGh1Yi5jb20vSG9sbzMxNC9mb3JjZUNsb3NhYmxlKSA8
c3BhbiB6ZXVtNGMxPSJQUl81XzAiIGRhdGEtZGRud2FiPSJQUl81XzAiIGFyaWEtaW52YWxpZD0i
Z3JhbW1hciIgY2xhc3M9IkxtIG5nIj5mb3I8L3NwYW4+IDxzcGFuIHpldW00YzE9IlBSXzZfMCIg
ZGF0YS1kZG53YWI9IlBSXzZfMCIgYXJpYS1pbnZhbGlkPSJncmFtbWFyIiBjbGFzcz0iTG0gbmci
PmVuZm9yY2VkPC9zcGFuPiBUd1IgYXMgYSBQb0MuPC9kaXY+" 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 Fri, Aug 5, 2022 at 2:21 PM Alan Bateman <<a href="mailto:Alan.Bateman@oracle.com">Alan.Bateman@oracle.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>
On 04/08/2022 20:35, Holo The Sage Wolf wrote:<br>
<blockquote type="cite">
<div dir="ltr">
<div><code></code>
<p style="margin:0px 0px 1.2em">Some implementations
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">Collection</code>
that will always fail, some will always succeed, and some
implementations (like <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">HashSet</code>)
may be non-deterministic.<br>
For the uninformed this method makes sense, for each <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">PartitiableAction</code>
I create some kind of a new “<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">Executor</code>“
that everyone is talking about, if one of the parts fails,
the whole calculation of this specific <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">PartitiableAction</code>
will stop running, and I am waiting for everything to end.<br>
</p>
</div>
</div>
</blockquote>
<br>
You may be right that someone may choose to ignore the javadoc, the
examples, and the recommendation to use try-with-resources but that
isn't a slam dunk argument for changing that API to use lambda
expressions and all the usability issues that it would bring. The
example is a bit strange, it seems to assume that any action can
process any input. Also the iteration order of "actions" can be
deterministic and it will still fail because it will attempt to
close the scopes in iteration order when it should be closing them
in reverse iteration order. So you should see an exception at
runtime if actions contains more than one element.<br>
<br>
In any case, I think this is just another reminder that having
language support that would somehow enforce the use of
try-with-resources would be very helpful here.<br>
<br>
-Alan<br>
</div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">Holo The Wise Wolf Of Yoitsu</div></div>