Automatic Resource Management, V.2
Joshua Bloch
jjb at google.com
Tue Apr 21 12:44:56 PDT 2009
Howard,
On Mon, Apr 20, 2009 at 8:22 PM, <howard.lovatt at gmail.com> wrote:
> I have a couple of reservations:
>
> 1. The use of try does not seem natural; it is too tied in my mind to
> Exceptions,
But there are exceptions involved here! A main point of the construct is
that it closes resources, even in the presence of exceptions. I think
that's why others find it so natural.
> can another keyword be used?
There's no technical reason not to, but we have to decide what's best from a
language-design standpoint.
>
>
> 2. If we are using the specific block approach, eg try (...) {...}, then it
> does not seem natural that for each or similar closes the resource. If the
> approach used automatic closure of a resource at the end of the block that
> the resource was declared in, then for each etc. closing the resource would
> seem natural. I prefer that the resource is automatically closed at the end
> of the block and therefore for each etc. would naturally close at the end
> of their block also; but if the majority thinks a dedicated block structure
> is better, then I suggest that for each etc. are left out.
Yeah, this could go either way.
>
> Having stated my reservations I would rather see the proposal, as is,
> included, rather than nothing at all.
>
> Also thanks to Josh for putting so much effort into this.
And thanks so much for your encouragement!
Josh
More information about the coin-dev
mailing list