Proposal: Automatic Resource Management
    Neal Gafter 
    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
Disposable.
 2. Statically test the static return type of iterableExpression.iterator(),
which due to covariance may be a type that extends both Iterable<?> and
Disposable.
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).
Cheers,
Neal
    
    
More information about the coin-dev
mailing list