Null-restricted types: Why so complicated?
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Fri Jan 19 21:58:58 UTC 2024
On 19/01/2024 19:34, John Bossons wrote:
> it's bad practice to specify arrays of null-restricted elements except
> where you're sure undefined elements are never read before being defined
Counter-argument: it is relatively common to create e.g. an array of
ints, which is then only populated sparsely. When you create an int[],
you can read its elements (and get a zero out), you don't get any
exception. Thanks to having defined values "the right way", that's
exactly what you get when you read a freshly minted V![]
(Subtle bonus point: because of this, `int` is effectively an alias for
`!Integer`).
We could have designed this differently, but then we would have ended up
in a place which was neither classes, nor primitives.
Maurizio
More information about the valhalla-dev
mailing list