Proposal: Automatic Resource Management
neal at gafter.com
Tue Sep 1 17:13:05 PDT 2009
On Tue, Sep 1, 2009 at 4:24 PM, Rémi Forax <forax at univ-mlv.fr> wrote:
> This will require to introduce a new interface IterableDisposable or
> something like that to ease the use of such pattern.
That's one way to do it. Here are two others:
1. Dynamically test the type of the iterator to see if it extends
2. Statically test the static return type of iterableExpression.iterator(),
which due to covariance may be a type that extends both Iterable<?> and
I think (2) works best, so that the compiler can see the exceptions
statically thrown by iterableExpression.iterator().close() and the
programmer won't have to catch(Exception).
More information about the coin-dev