Are NPEs harder to handle safely, compared to other exception types?
-
-
-
Yes. When you dereference a pointer you have to make sure that something safe happens if that pointer is null. It’s not as simple as making sure that the zero page is unmapped and catching SIGSEGV because you might overshoot the page if it’s e.g. an array.
- 7 more replies
New conversation -
-
-
Are you saying C decided correctly that functions can’t be null?

-
Wait, function pointers can’t be null in C?
- 3 more replies
New conversation -
-
-
So optionals are something different for the purposes of code generation? Because coders have to explicitly check for unset values and you can then just assume it's not nil?
-
Right.
End of conversation
New conversation -
-
-
How do you return a pointer from a function that might fail?
-
Option types or explicitly nullable pointer types
- 1 more reply
New conversation -
-
-
What is the preferred alternative?
-
Don't have automatic zero initialization (or uninitialized data usage) and don't support null as a value for assignment to pointers. You won't have null pointers. An optional value isn't usually what's wanted and when it's desired it can and should be done explicitly instead.
- 12 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.