[haXe] type parameters and covariance
Nicolas Cannasse
ncannasse at motion-twin.com
Tue Feb 13 16:55:09 CET 2007
> Hey Nicolas,
>
> with interest i've read your blog post about covariance. Have you made any progress by now, or is the "problem" deferred? I would really like to use a Foo<B> for a Foo<A> if B extends A...
>
> -dan
You can write : Foo<+A>, but that will restrict the actual prototype of
Foo. Some methods will not be accessible because the compiler guess they
are "writing" A, while it's maybe an actual Foo<B> where you can only
"write" B instances.
Think about Array.push for an example.
Nicolas
More information about the Haxe
mailing list