On 08/02/2010 11:27 PM, bearophile wrote:
Ryan W Sims:
The problem isn't how to check it on a case-by-case basis, there are
plenty of ways to check that a given pointer is non-null. The problem is
debugging _unexpected_ null dereferences, for which a NPE or its
equivalent is very helpful, a segfault is _not_.
I don't know what NPE is, but if you program with DbC your nulls are very often
found out by asserts, so you have assert errors (that show line number& file
name) instead of segfaults.
Null Pointer Exception! However, I agree with getting segfaults from
them. Otherwise, you will be tempted to use the exception handling
mechanisms to catch null pointer exceptions, which is a bad thing.
I also agree with the notion of using DbC to find nulls.
What I really wish for is non-nullable types, though. Maybe in D3... :P