(non)nullable types
Sebastian Biallas
groups.5.sepp at spamgourmet.com
Mon Feb 9 10:33:58 PST 2009
Christopher Wright wrote:
> Oh, and I vote no. I think it's needless complexity. I code without any
> special care for null objects, and I get a segfault or
> NullReferenceException maybe once a week, probably less. I've always
> been able to track down the bug very quickly.
That misses the point completely. It's not about you (as the programmer)
getting NPEs; it's about the user getting bug-free software in the first
place.
In most cases a segfault/NPE is easy to track down for the programmer, I
guess nobody would object to this. But once the software is shipped,
it's a very serious problem: It's a situation the programmer didn't
thought about so you usually have a data loss.
I really like the approach of the Nice[1] language: Before you can
access a nullable type you have to test whether it's null. After the
test, the type is automagically converted to a nonnullable type. This
language doesn't have a NPE, so you *know* that your software is
bug-free in this regard.
[1] http://nice.sf.net
Sebastian
More information about the Digitalmars-d
mailing list