Re:The Road to Valhalla
by akkartik on Friday December 06, 2019 @09:01PM
(#21727947)
I wonder if they plan to support nested inline types, such as arrays inside objects, or arrays in arrays. Every time I try to design a layout something like that I end up having to compute values to initialize various offsets with. Arrays may have a length prefix, or objects may need some metadata in the header. Tagged unions may need to initialize tags.
[ Parent
| on HN ]
Reading the doc, I believe this is supported with these restrictions: (1) value classes may only contain other value classes, and (2) value classes cannot contain instances of themselves (no circularity).
Your first point is incorrect, inline classes can have fields that are regular reference types.
Interesting; I must have “over-read” the restriction. You are correct.
Re-reading the doc, the restriction is that all fields of a value type must be final, because value objects do not have identity.