Re: Reified types and primitives
- From: Mark Space <markspace@xxxxxxxxxxxxxx>
- Date: Mon, 19 May 2008 12:47:20 -0700
Roedy Green wrote:
On Sun, 18 May 2008 20:50:40 -0700, Mark Space
<markspace@xxxxxxxxxxxxxx> wrote, quoted or indirectly quoted someone
who said :
useful. Boxing and unboxing does take time, and that could be unacceptable for some types of applications.
Eiffel has some way of treating primitives as Objects, but without the
overhead. It might be productive to find out how their scheme works
to see if any of it would be applicable to Java.
I was thinking that with reifiable types, the class or object could get a reference to a Class type that describes the type. (I assume this is what has to happen for reifiable types anyway.)
So for some class
public Point3D<class T implements double.class, float.class>
{
T x, y, z;
}
the compiler will have to add a field for the class type. This type could be used to "treat primitives like objects."
It depends on exactly what operations one needs to perform on primitives that are "like a class." Determining those operations is probably the hard part.
BTW, if Point3D is reifiable, what is the class type? I don't think it's Point3D anymore. So, can I get it's type with a literal still? Will something like "this.class" be available? Or will I have to call "this.getClass()?" It seems like the latter is also a requirement. Plus, it might be an error to invoke a class literal on a class that hasn't been parameterized yet.
Point3D.class == we don't know yet, throw an error.
This reifiable proposal for Java 7 has some funny corners.
(This one, I mean:
<http://tech.puredanger.com/java7/#reified> )
.
- References:
- Reified types and primitives
- From: Mark Space
- Re: Reified types and primitives
- From: Roedy Green
- Reified types and primitives
- Prev by Date: Re: Reified types and primitives
- Next by Date: Re: Reified types and primitives
- Previous by thread: Re: Reified types and primitives
- Next by thread: Re: Reified types and primitives
- Index(es):