Proposal: Automatic Resource Management
Peter Mount
peter at retep.org.uk
Sun Mar 8 00:03:17 PST 2009
On Sun, Mar 8, 2009 at 7:58 AM, Jeremy Manson <jeremy.manson at gmail.com>wrote:
> 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".
What about when someone just references the lock as Lock rather than the
implementing class? Javac won't be able to determine that the lock
implements Disposable so in that case it will fail..
>
>
> 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
> >
> >
> >
>
>
--
Peter Mount
e: peter at retep.org.uk
w: http://retep.org
Jabber/GTalk: peter at retep.org MSN: retep207 at hotmail.com
More information about the coin-dev
mailing list