Proposal: Simplified syntax for dealing with parameterized types (correction to ALTERNATIVES section)

Howard Lovatt howard.lovatt at iee.org
Mon Mar 23 15:33:31 PDT 2009


Hi,

There is a lot to like with proposal since class StringList =
ArrayList<String> would both shorten declarations and would partially
reify the generic class. However there is a problem touched on in the
proposal namely class MyStringList = List<String> then StringList sl =
...; MyStringList msl ...; sl = msl; // Error. This problem is worse
than suggested in the proposal, consider alternate implementations of
the same interface:

class StringList = List<String>;
class ArrayStringList = ArrayList<String>;

StringList sl = new ArrayList(); // Error

I think to make this workable you need to either:

1. change the mechanism so that the interface and abstract class
version is simply a shorthand and does not create a new class or type
(i.e. simply a type alias), or

2. alternatively just drop the interface/abstract class bit altogether
and say the new mechanism can only be applied to non-abstract classes.


  -- Howard.



More information about the coin-dev mailing list