valhalla-dev Digest, Vol 7, Issue 26
Vitaly Davidovich
vitalyd at gmail.com
Thu Jan 8 00:33:44 UTC 2015
But if you're taking the conservative approach then you can only be calling
that one Object overload (you can't overload by return value only) and then
where's the specialization?
Sent from my phone
On Jan 7, 2015 7:24 PM, "Thomas W" <twhitmore.nz at gmail.com> wrote:
> Hi Vitaly, good questions.
>
> Luckily there are good answers :)
>
> > So say I'm authoring a generic class and call System.out.println() -
> how do I know which method is going to be called?
>
> The most specific one, matching the specialized type of your 'any T'
> parameter.
>
> > Suppose println returned different types depending on overload - what's
> my return value type? I can't target type it because that implies I know
> what the generic type will be and I don't, I'm just shipping a generic
> library.
>
> Since we're conservative, we should only consider methods having a
> return-type/ signature consistent with the "base" method. This means we
> look at the signature of PrintStream.print(Object arg) and only consider
> methods consistent with that. I think that would work fine, and be both
> conservative & reliable.
>
> Would that work for you?
>
> I did see that Brian suggested some kind of explicit enhancement of
> existing libraries.. not sure if that's a "print(any T)" method, or if
> so, how it would actually implement/ or despatch efficiently.
>
>
> Regards,
> Thomas
>
More information about the valhalla-dev
mailing list