Proposal: Automatic Resource Management
Jeremy Manson
jeremy.manson at gmail.com
Sat Mar 7 23:58:02 PST 2009
I am aware Lock is an interface. You wouldn't actually change the
Lock interface, you would change the classes. Just as they retrofit
Iterable everywhere. That's why I put "class Lock" there; perhaps it
would have been clearer if it said "class MyLock".
Jeremy
On Sat, Mar 7, 2009 at 10:23 AM, Stephen Colebourne
<jodastephen at gmail.com> wrote:
> Jeremy Manson wrote:
>> The "right" fix, if we want to support this pattern, is to allow the
>> try resource statement to accept expressions that return Disposables,
>> and to retrofit the relevant lock APIs with disposables and lock
>> methods that return this:
>>
>> class Lock implements Disposable {
>> public Lock dlock() {
>> return this;
>> }
>> @Override public void dispose() {
>> unlock();
>> }
>> }
>>
> Lock is an interface. No changes are possible.
>
> Stephen
>
>
>
More information about the coin-dev
mailing list