NULL has a type, damn it!
At least it does in my view of the world.
To me NULL means: No statement can be made about the VALUE of this TYPE.
You can't avoid knowing the type of value you're expecting from 1st normal form out.
SQL_VARIANT *is* a TYPE. The fact that it's non-atomic will cause you problems, but it is a type nonetheless.
In an imperative environment, operations on NULL values should throw exceptions. TVL is only useful for SET based operations.. it's a super bad idea for imperative code, IMO (from the POV of managing complexity).
Generally you have to allow for the possibility that *any data* can be NULL at *some point in time*.
Perhaps it would have been best if System.Object defined a Boolean IsNull { get; } property.. with semantics that applied to 'value types' and 'reference types' appropriately, and that basically threw “Null[Reference|Value]Exception” if any attempt to operate on a NULL value was made (beyond the .IsNull query).
I haven't spent any amount of time mulling it over, but at first glance I really like your idea about Object.IsNull.
Do you think nullable types are going to solve our null issues in The Next Release? I'm optimistic... but I'm also realistic... so I just don't know. ;)
Here's a link to a C# library at sourceforge called NullableTypes. I've never used it, but have friends that use and like it. Regardless of what it does though, still doesn't get around the fact that primative types don't support NULL values, and that just really, really sucks.
http://sourceforge.net/projects/nullabletypes/
Stuart,
I'm just thinking out loud. I haven't had a look at the new nullable capabilities (in C# 2.0, or whatever). I'm really hoping they haven't implemented Three Value Logic (TVL) but I fear that they may have..
I haven't thought too hard about Object.IsNull either. It would increase complexity, but at the same time it would increase 'uniformity'..
Ray,
I know about Luka's NullableType library. I've spoken with him about it before, and thought long and hard about it. I ended up writing my own library instead of using Luka's one, because he implemented TVL, and I think that's a bad idea. (I didn't think it was a bad idea to start with).
John.
p.s. I've decided to walk away from NULL altogether. The current version of my database doesn't have a single nullable field.