valhalla-dev Digest, Vol 7, Issue 26

Thomas W twhitmore.nz at gmail.com
Wed Jan 7 23:21:47 UTC 2015


Hi Peter, Vitaly,

Thanks for your interesting ideas. Vitaly says:

> Personally I'd handle primitives as if they were value types from day 1:
> they get Object's hashCode, equals, and toString by allowing T.toString
and
> rewriting it to their corresponding XXX.toString.

Sounds great, we need good basic integration of primitives & value types.
Let's do it.

Peter says:

> While experimenting a bit with the current preliminary prototype, I found
> myself on several occasions wanting to call a method from "normal" API.
Say
> System.out.println(x) with an x of type "any T". Usually a method that
> already has various overloads or a method taking an Object. Javac refuses:
>
>      PrintStream.println(boolean)
>      PrintStream.println(char)
>      PrintStream.println(int)
>      ..
>      PrintStream.println(String)
>      PrintStream.println(Object)

This pattern is absolutely typical of existing "vari-typed" Java code &
libraries. It's the only efficient way to receive an argument that may be
of (logically) any type, and process that argument.
I absolutely think this is something which we should target, and the
specializer should be able to do.

Essentially, this is our specialized code's interface to "the rest of the
Java world". It really should be able to be efficient.

Equals, hashCode and toString only take us so far..  there are a world of
other interactions, which -- if designed for performance -- will be written
in a similar manner to these.


Regards,
Thomas Whitmore



More information about the valhalla-dev mailing list