News for hackers. Stuff that matters.
Re:Avoid NULL by AnimalMuppet on Monday November 09, 2015 @05:35PM (#10536341)
> All pointer types are nullable, and no non-pointer types are nullable.

It's also error numbers. Yeah, they're just an int as far as types go, but they also have nullable semantics, with 0 being "no error". So it's not just pointers (quite).

> You're right that an optional type is actually two types. But it's designed such that you can't get at the underlying runtime type without first checking to see what it is. That's a huge difference.

Agreed.

Re:Avoid NULL by mikeash on Monday November 09, 2015 @05:54PM (#10536430)
I disagree that error numbers are nullable. It's just an integer, and there's nothing special about the zero integer. It's not like pointers where if you dereference NULL, you've hit a special case where anything could happen. There's a difference between a language-level NULL, as pointers have, and a value with no special language meaning which you give special meaning at a higher level.

If you want an example of a non-pointer nullable type, float and double probably qualify. Both can be NAN, which is effectively NULL for floats. Like NULL, NAN behaves completely differently from any other value and only convention and documentation tell you whether any particular place might produce or accept it.

Re:Avoid NULL by AnimalMuppet on Monday November 09, 2015 @06:21PM (#10536555)
Don't forget about signalling vs. non-signalling NANs...