valhalla-dev Digest, Vol 17, Issue 5

Thomas W twhitmore.nz at gmail.com
Mon Dec 14 07:15:54 UTC 2015


Hi Timo,

You seem to be asking about bit-level patterns -- is that for the purpose
of 'sentinels'?  My position is with Brian, that exposing the bit-level
representation is completely undesirable. T.default is intended to provide
a good 'default value' for eg. empty cells in a collection to default to.

Previously, however, I did propose a 'T.sentinel' capability, which would
have provided a "reasonable" sentinel value for most types. Reasonable, not
perfect, since sentinels are a compromise & prevent use of the complete
value-space for the type.

Nevertheless, I believed there was substantial usefulness & value in having
such a capability available. Part of the rationale is that "null" for
references has two common uses;  1) as a default, 2) as a sentinel. For
numeric primitives, by comparison, the default (zero) is far too important
as a value to be a reasonable sentinel.

I would obviously not see the standard Java collection implementations
using these, but for specialized/ custom collections, I'd still advocate
the value of exposing that.

int.sentinel = Integer.MIN_VALUE
double.sentinel = NaN
Object.sentinel = null
etc.

'boolean' would be the only case not well supported.


Would you support that as useful, Timo?


Regards,
Thomas


More information about the valhalla-dev mailing list