Proposal: Automatic Resource Management

Neal Gafter neal at
Tue Sep 1 22:04:54 PDT 2009

On Tue, Sep 1, 2009 at 9:01 PM, Joshua Bloch <jjb at> wrote:

> Many existing types will be retrofitted to extend Disposable.  If such a
> type also implements Iterable, the semantics of a for-each loop on an
> instance of the type would change, as I understand Sean's suggestion.


In theory, yes.  However, I doubt you'll find a confluence of events that
would cause the change of behavior: (1) an existing implementation of
Iterable that make use of covariant returns to (2) return a type that will
be retrofitted with Disposable and is (3) used in a for-each loop in some
existing client code.  If you do find such a case, you've found a resource
leak in existing code, and its maintainers should be glad to have the change
in behavior.


More information about the coin-dev mailing list