3 ms·
What JVM instructions would you use to implement user-defined value types?
by quotemstr 12y ago
What 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).