5 ms·
I had heard a rumor that there ware talks of user defined value types. Does anyone know if there is any hope for this?
by stusmall 12y ago
I had heard a rumor that there ware talks of user defined value types. Does anyone know if there is any hope for this?
- quotemstr 12y agoWhat JVM instructions would you use to implement user-defined value types?
- Padding 12y agoI'm not sure you'd need to introduce new instructions. "user-defined value types", i.e. structs, can already be done today by (ab)using the Flyweight pattern and storing data (possibly off-heap with RAII rather than GC semantics) in some byte[]. All a JDK-supplied implementation would really need to do is (1) automate/hide all the painful work necessary to set this up and (2) provide syntactic sugar in the form of operators that can directly manipulate members of these types (+fast implicitly inlined implementations of them, specialized on the member types).
- danieldk 12y agoIt seems that it is almost in prototyping stage, the usual suspects have already written a sketch of a future proposal: http://cr.openjdk.java.net/~jrose/values/values.html http://cr.openjdk.java.net/~jrose/values/values.html
- stusmall 12y agoAwesome! Thanks. I don't know much about the path from idea to standardized feature with the JVM. Is there hope for it in Java 9 or is this much farther out in the future? Probably first and more importantly, what is the chance for this even ever happening?
- hyperpape 12y ago"the path from idea to standardized feature" Guy Steele was asking for value types in 1998 (http://www.cs.virginia.edu/~evans/cs655/readings/steele.pdf http://www.cs.virginia.edu/~evans/cs655/readings/steele.pdf)
- Padding 12y agoYeah, but he was also asking for operator overloading.
- karianna 12y agoLikely delivery timeframe for value types in Java 10. Definitely not Java 9. Source - many conversations with Brian Goetz et al.