Proposal: Automatic Resource Management
Joshua Bloch
jjb at google.com
Sat Mar 7 10:19:56 PST 2009
If people feel that the locking case is important, I encourage them to
pursue it with another proposal. I suspect that it won't be difficult to
write. But I am less certain that it will pay for itself. I believe that
the cost-benefit ratio for "true resources" is much higher than for locks.
When Doug was working on JSR 166 we discussed linguistic support, but he
never really felt the need.
Josh
On Sat, Mar 7, 2009 at 10:15 AM, Stefan Schulz <schulz at e-spirit.de> wrote:
> Jeremy Manson wrote:
> > try (lock.dlock()) {
> > // ...
> > }
>
> The problem with this solution is that lock implements Disposable and
> may be used in the try statement directly, without any error being
> visible at compile time (and maybe non-deterministically failing at
> runtime). The "dlock()" might return a Disposable, but it should at
> least be some wrapper on the lock instance.
>
> Btw., allowing for expressions instead of assignments only is some
> additional syntactic sugar adding a temporary variable for the assignment.
>
> Stefan
>
>
More information about the coin-dev
mailing list