Mappers and variance

Luc Duponcheel luc.duponcheel at gmail.com
Mon Jun 25 12:20:52 PDT 2012


Hi,

First of all, sorry if this has been asked before...

In Java variance has a "use-site" implementation (while in Scala it has a
"declaration-site" implementation... so far so good (or bad (?)).

The Mapper(s) composition methods deal with variance for their arguments,
but not for their return type.
I can understand this because of the complexity caused by the "use-site"
decision (super and extends are very intrusive at use-site).

But is there any use case for argument variance (apart from "just in case")?

Maybe downward compatibility (I mean, maybe there are static methods in the
standard library that use contravariance for their return type and
covariance for their argument type?

Just curious...

Luc


More information about the lambda-dev mailing list