ARM syntax and new keywords

John Hendrikx hjohn at xs4all.nl
Fri Nov 27 16:50:03 PST 2009


Reinier Zwitserloot wrote:
> @Cleanup is by far my favourite lombok annotation. Experience working with
> it in real code has led me to the conclusion that having cleanup work on a
> variable until it runs out of scope, instead of introducing a new block, is
> a considerably more natural way to do this. There's far less syntax involved
> (just 1 simple marker on a variable declaration, nothing else, and no new
> blocks), which really says it all.
>   
Yes, I'm actually a bit surprised that the ARM syntax currently favors 
the try syntax.  Why not simply call a method on any object going out of 
scope if it implements a certain interface?  It would be like finalize, 
except it would have clearly defined semantics making it useful for 
automatically cleaning up your resources (ie, it would be called as soon 
as it goes out of scope).

Exceptions being thrown from such a close method should in my opinion 
simply be disallowed.  If your auto cleanup block can't do it's thing 
without throwing exceptions, then use something else.

All this fooling around with annotations, keywords and resource blocks 
when a decent implementation of finalize could do the trick far easier 
seems odd to me.




More information about the coin-dev mailing list