I liked the discussion of Generics Differences , and was wondering if there were any languages that used this feature particularly well.
I really don't like Java List<? extends Foo> List<? extends Foo> for a List things that are Liskov-substitutable for Foo . Why can't List<Foo> cover this?
And frankly, Comparable<? super Bar> Comparable<? super Bar> ?
I also can’t remember my life, why you should never return an array of generics:
public T[] getAll<T>() { ... }
I never liked C ++ templates, but that was mainly because none of the compilers could throw out a remote error message for them. Once I actually did make realclean && make 17 times to compile something; I never understood why the 17th time was a charm.
So who really likes to use generics in their favorite language?
language-agnostic generics
James A. Rosen
source share