int types and null

Alan Snyder fishgarage at cbfiddle.com
Thu Sep 22 22:41:09 UTC 2022


After reading the JEPs, I’m wondering whether any consideration has been given to allowing an int based value type to define a distinguished int value to be used as the representation of null when using the value in a context where null is possible, such as a type parameter.

I have often used a distinguished integer to represent the “unspecified” case and mapping that to null would allow the type to fit nicely with APIs that use null for the same purpose.

The concept might be realized by providing implementations of designated conversion methods.

(I may not be using the correct terminology, but I hope the example is clear.)



More information about the valhalla-spec-comments mailing list