Introduce Covariance/Contravariance at declaration site for Java 9 ?
Remi Forax
forax at univ-mlv.fr
Mon Oct 15 17:40:43 PDT 2012
On 10/16/2012 02:24 AM, Joshua Bloch wrote:
> I believe that declaration site variance annotations are every bit as
> bad as use-site annotations. They're bad in a different way--they
> force you to write idiosyncratic types because natural types don't
> lend themselves to fixed variance restrictions--but they're still bad.
> Providing both use and declaration site variance in one language is
> the worst of both worlds (unless you're trying to kill the language).
I agree that declaration variance as an effect on the way of people
write APIs,
and also agree that mixing the two kind of variance just makes things
more complex to understand.
The real issue is to having variance on SAMs, so it can be restricted
only to SAM type.
In that case, the variance can be inferred using the SAM descriptor
without having
to require user declaration.
So instead of declaration site variance, let's call it infered variance
at use-site for function type.
>
> Josh
Rémi
>
> On Mon, Oct 15, 2012 at 3:09 PM, Remi Forax <forax at univ-mlv.fr
> <mailto:forax at univ-mlv.fr>> wrote:
>
> I've just read the presentation of Stuart Marks at JavaOne [1],
> all examples after slide 32, the first one that use lambdas are
> not written correctly
> because all method signatures do not use wildcards.
>
> Brian, I know that we will not be able to introduce
> covariance/contravariance
> at declaration site for Java 8, so the solution we will deliver
> will be far from perfect
> because nobody understand wildcards.
> Is there a way to free Dan and Maurizio enough time to investigate if
> covariance/contravariance can be added to Java 9.
>
> Rémi
> [1]
> https://stuartmarks.wordpress.com/2012/10/07/javaone-2012-jump-starting-lambda-programming/
>
>
More information about the lambda-libs-spec-observers
mailing list