4 ms·
Off the top of my head, I don't think there is, but not due to some objections to the feature, but because doing this is a pretty niche feature (pun absolutely
by steveklabnik 6y ago
Off the top of my head, I don't think there is, but not due to some objections to the feature, but because doing this is a pretty niche feature (pun absolutely intended.) Nobody has been motivated enough to do the design and consensus building work.
- vlovich123 6y agoThis came up a ton when I was doing particle filters on mobile. We had optional doubles that were initialized to NaN but NaN isn't a valid value. Being able to use optionals instead would be great (to avoid having to backtrace where an accidental NaN propagation may have started from) but the memory hit was impractical. I bet some parts of the science community might need this but the need is so spread out (each individual application) that it might not be as obvious as a popular library identifying the need. I wish I knew language design & compiler development better & had the time to propose it & see it through.
- conradludgate 6y agoFiniteFloat or NotNaN would be nice additions to the stdlib
- jsheard 6y agoNonMax types would be nice to have, since the natural "null" value for an index into some linear data structure is the highest one In the meantime it can be done by wrapping NonZero and storing !value, but that's a (tiny) runtime overhead on each get/set