Re:Switching from C# to Java
by thejake on Tuesday April 13, 2010 @08:05AM
(#1261679)
The case that I've bumped up against several times is when trying to get the class of the generic object. Something like:
This type of operation is most useful if writing framework type of some sort. I've come across it when trying to write a generic JPA base DAO type of class.
[ Parent
| on HN ]
Scala has Manifests to emulate reified types for just this reason.
http://www.scala-blogs.org/2008/10/manifests-reified-types.h...
It's improved a bit in 2.8 - in porting some code I discovered a nice little hack that lets you declare your variance like this:
[A <: SomeBaseClass <: Manifest]
Which tells the compiler in an oh so gentle manner to reify for you.