Notes on implementing concise calls to constructors with type parameters

Neal Gafter neal at gafter.com
Wed May 13 21:15:22 PDT 2009


Like Reiner, I suppose you have in mind a specification that would result in
the behavior you want without any undesireable side-effects.  I look forward
to seeing that spec.  Until then, there isn't really much to comment on.

Regards,
Neal

On Wed, May 13, 2009 at 8:41 PM, Howard Lovatt <howard.lovatt at iee.org>wrote:

> The suggestion from Reinier that:
>
> List<String> foo = new ArrayList();
>
> infers ArrayList<String>, seems like a good idea to me (for one thing
> it is consistent with how you use generic static methods and as Ulf
> pointed out people already write this and suffer the warnings). Also
> the present system, because or erasure, isn't type safe as it stands,
> e.g.:
>
>    final List<String> ls = new ArrayList<String>();
>    final List lr = ( List ) ls;
>    lr.add( 1 );
>    System.out.println( " ls = " + ls );
>
> and Reinier's change would if anything increase type safety.
>
> Even if there are some minor incompatibilities, it would be worth it.
> I am not a fan of the <> syntax, it looks ugly and if anything implies
> raw type to me rather than inferred type. A further suggestion along
> Reinier's lines, allow:
>
> ArrayList<String> foo = new();
>
> to be equivalent to:
>
> ArrayList<String> foo = new ArrayList<String>();
>
>
>  -- Howard.
>
>



More information about the coin-dev mailing list