I liked the discussion at Differences in Generics, and was wondering whether there were any languages that used this feature particularly well.
I really dislike Java's List<? extends Foo>
for a List
of things that are Liskov-substitutable for Foo
. Why can't List<Foo>
cover that?
And honestly, Comparable<? super Bar>
?
I also can't remember for the life of my why you should never return an Array of generics:
public T[] getAll<T>() { ... }
I never liked templates in C++, but that was mostly because none of the compilers could ever spit out a remotely meaningful error message for them. One time I actually did a make realclean && make
17 times to get something to compile; I never did figure out why the 17th time was the charm.
So, who actually likes using generics in their pet language?