Null references redux
Denis Koroskin
2korden at gmail.com
Sat Sep 26 15:17:00 PDT 2009
On Sun, 27 Sep 2009 01:49:45 +0400, Walter Bright
<newshound1 at digitalmars.com> wrote:
> The problem with non-nullable references is what do they default to?
> Some "nan" object? When you use a "nan" object, what should it do? Throw
> an exception?
>
Oh, my! You don't even know what a non-null default is!
There is a Null Object pattern
(http://en.wikipedia.org/wiki/Null_Object_pattern) - I guess that's what
you are talking about, when you mean "nan object" - but it has little to
do with non-null references.
With non-null references, you don't have "wrong values", that throw an
exception upon use (although it's clearly possible), you get a correct
value.
If an object may or may not have a valid value, you mark it as nullable.
All the difference is that it's a non-default behavior, that's it. And a
user is now warned, that an object may be not initialized.
More information about the Digitalmars-d
mailing list