<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
I think Mark’s solution is quite practical. I think you’re greatly overestimating the benefits (“enormous ergonomic advantage”) of your idea (a common trap to fall into) and enormously^2 underestimating where the bar is for “add features to everyone’s Java.”
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">
<div class="">
<div class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Dec 27, 2022, at 9:16 AM, Red IO <<a href="mailto:redio.development@gmail.com" class="">redio.development@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="auto" class="">This is a nice workaround but allocates additional resources and adds clutter in form of (still) a level of nesting and an unnecessary collection. Considering that try resource is only a syntactic sugar. It shouldn't be difficult to
add this simple addition of syntax to provide this enormous ergonomic advantage. Also I think it's unlikely that try (... ); would find another useful use. </div>
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Tue, Dec 27, 2022, 15:07 Mark Raynsford <<a href="mailto:org.openjdk@io7m.com" class="">org.openjdk@io7m.com</a>> wrote:<br class="">
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 2022-12-27T14:49:13 +0100<br class="">
Red IO <<a href="mailto:redio.development@gmail.com" target="_blank" rel="noreferrer" class="">redio.development@gmail.com</a>> wrote:<br class="">
><br class="">
> Sometimes we need to initialize something between the resources and we get<br class="">
> multiple levels of nesting.<br class="">
> And I was wondering if we could not just lose the block and auto close at<br class="">
> the end of a method like this :<br class="">
<br class="">
I work with Vulkan a lot, and that involves a metric ton of closeable<br class="">
resources that also have to be closed in stack order. I have a<br class="">
library-level solution for this:<br class="">
<br class="">
<a href="https://www.io7m.com/software/jmulticlose/" rel="noreferrer noreferrer" target="_blank" class="">
https://www.io7m.com/software/jmulticlose/</a><br class="">
<br class="">
-- <br class="">
Mark Raynsford | <a href="https://www.io7m.com/" rel="noreferrer noreferrer" target="_blank" class="">
https://www.io7m.com</a><br class="">
<br class="">
</blockquote>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
</div>
</body>
</html>