slam dunk argument for changing that API to use lambda expressions 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.
I wrote a simple error-prone plugin <https://github.com/Holo314/forceClosable> for enforced TwR as a PoC. On Fri, Aug 5, 2022 at 2:21 PM Alan Bateman <alan.bate...@oracle.com> wrote: > On 04/08/2022 20:35, Holo The Sage Wolf wrote: > > Some implementations of Collection that will always fail, some will > always succeed, and some implementations (like HashSet) may be > non-deterministic. > For the uninformed this method makes sense, for each PartitiableAction I > create some kind of a new “Executor“ that everyone is talking about, if > one of the parts fails, the whole calculation of this specific > PartitiableAction will stop running, and I am waiting for everything to > end. > > > 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. > > 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. > > -Alan > -- Holo The Wise Wolf Of Yoitsu