Proposal: Access to Generic Type Parameters at Compile-Time
David Walend
david at walend.net
Tue Mar 17 19:35:56 PDT 2009
Hi Mark,
On Mar 17, 2009, at 12:22 PM, Mark Mahieu wrote:
> Hi David,
>
> On 17 Mar 2009, at 02:37, David Walend wrote:
>>
>> interface Path<ThruGraph extends Digraph>
>> extends Digraph<ThruGraph.Node,ThruGraph.Edge>
>> {
>> ThruGraph.Node getHead();
>> ...
>> }
>
> So, if I were the author of Digraph and I decided to rename its type
> parameters (to N and E for example), your Path interface would no
> longer compile?
That's correct. Changing the name of a type parameter would have the
same potential impact as renaming other public/protected/default-
accessible parts of the class, like an inner class, a static method or
a static member field.
Changing an extends or super clause risks breaking something. Adding
or removing type parameters almost always breaks downstream code that
uses the class. The name of the type parameter is (I think) the only
thing you can safely change in the parameter list currently.
I think this problem would come up far less often than breaking the
interface by adding an extends or super clause to an existing
parameter. Is it a big enough problem to add to the disadvantages list?
Thanks,
Dave
David Walend
david at walend.net
More information about the coin-dev
mailing list