lazy statics design notes
Brian Goetz
brian.goetz at oracle.com
Fri Mar 1 00:54:00 UTC 2019
> The limitation against T.default can be spun, to many users, as a common sense
> error check, against uninitialized variables. To more curious users, it can be spun
> as a conscious reservation for efficient implementations.
This is justifiable for (most) ref types, but what about numeric
types? I can imagine many potentially-expensive computations that
could reasonably sum to zero. (And as you point out, the smaller the
range, the more silly this gets, ending with boolean.) So if we're
going to have this restriction, it should be restricted to class types,
and the recommended workaround be some sort of Optional or box. And
given that not all values will be null-default, it rules out any value
types for which the zero answer is a reasonable answer. I think this
edge is sharper than it looks.
More information about the valhalla-spec-observers
mailing list