On Saturday, 4 January 2014 at 22:06:13 UTC, Walter Bright wrote:
I don't really understand your point. Null is not that special.

For example, you may want a constrained type:

1. a float guaranteed to be not NaN
2. a code point guaranteed to be a valid code point
3. a prime number guaranteed to be a prime number
4. a path+filename guaranteed to be well-formed according to operating system rules
5. an SQL argument guaranteed to not contain an injection attack

The list is endless. Why is null special?

Because it is an instant crash, because it is not possible to make it safe without runtime check, because it is known to fool optimizer and cause really nasty bugs (typically, a pointer is dereferenced, so the optimizer assume it isn't null and remove null check after the dereference, and then the dereference is removed as it is dead. a bugguy code that could have crashed will know behave in random ways).

On the other hand, it is really easy to make all of this burden disappear at language level.

2 should also be ensure by @safe .

3, 4, 5 can easily be ensured by current type system.

I'm not knowledgeable enough on floating point standard to express any opinion on 1.

Reply via email to