Feedback and comments on ARM proposal

Mark Mahieu markmahieu at
Sat Mar 21 14:26:15 PDT 2009

On 21 Mar 2009, at 18:01, Joshua Bloch wrote:
>  I don't think I did a good job of explaining the problem. Consider  
> this:

Ah, ok I'm with you!  Thanks for the explanation.

> The problem with Nope is that it contains two "magic  
> methods"  (sole parameterless method in an interface that directly  
> extends MagicMarker).  Is it sufficient to say that a class must  
> have one and only one magic method to make it eligible for  
> automatic resource management?

Right, clearly we'd need to be more specific about all this.  I guess  
I should offer something up, so here's a first stab at it (caveat:  
not JLS-quality):

A variable/expression with static type T is eligible for automatic  
resource management iff T has exactly one method m for which all of  
the following hold:
	* m has no parameters
	* there exists one or more type S where:
		* S declares exactly one method, which is override-equivalent with m
		* S is an interface which directly extends MagicMarker
		* S :> T

I suppose we might also want to consider whether it should be an  
error for a class to implement MagicMarker directly, or for an  
interface that extends it to supply the 'wrong' number/type of  
methods, etc.

>  Is it practical to implement this in the compiler? I dunno.

To me, it bears more than a passing resemblance to determining the  
single-abstract-method in CICE, and I don't remember that aspect as  
being particularly difficult to implement.  Purely anecdotal though,  
of course.

>          Josh


More information about the coin-dev mailing list