Null references (oh no, not again!)

Sean Kelly sean at invisibleduck.org
Wed Mar 4 08:29:20 PST 2009


Walter Bright wrote:
> Daniel Keep wrote:
>> I need to know when that null gets stored, not when my code trips over
>> it and explodes later down the line.
> 
> Ok, I see the difference, but I've rarely had any trouble finding out 
> where the assignment happened. In fact, I can't remember ever having a 
> problem finding that.
> 
> That's because the null pointer exception is nearly always repeatable, 
> so it isn't hard to work backwards. The non-repeatable ones have been 
> due to memory corruption, which is a different issue entirely.

In a language like Java where basically every variable is a reference, 
it can be a lot more difficult to figure out where a null came from. 
I've never had this problem in code I've written either, but I've had to 
maintain some Java code that was nearly impenetrable and this was 
absolutely an issue.


Sean



More information about the Digitalmars-d mailing list