On 2/1/14, 7:14 AM, Jonathan M Davis wrote:
In the general case, you can only catch it at compile time if you disallow it completely, which is unnecessarily restrictive. Sure, some basic cases can be caught, but unless the code where the pointer/reference is defined is right next to the code where it's dereferenced, there's no way for the compiler to have any clue whether it's null or not.
This is not true. It's possible to do this, at least for the case where you dereference a variable or an object's field. See this:
http://crystal-lang.org/2013/07/13/null-pointer-exception.html