(non)nullable types

Christopher Wright dhasenan at gmail.com
Sat Feb 14 09:48:04 PST 2009


Jarrett Billingsley wrote:
> On Sat, Feb 14, 2009 at 8:37 AM, Christopher Wright <dhasenan at gmail.com> wrote:
>>> void Foo(void delegate()? dg) //nullable
>>> {
>>>    dg();
>>> }
>> You're right for that small example. Now let's say you have an object a
>> dozen methods referencing the same nullable member. They're private methods
>> called by public methods that check if the member is null first. I don't
>> want to have to check whether the variable is null every single time I use
>> it; I want to do it once at the start and assume (since it's a
>> single-threaded application and I'm not assigning to that member) that that
>> check works for everything.
> 
> ....that's the entire point of non-null references.

No. I'm saying this class has a complex code path if some things are not 
null, and some other code path if they are null. It's quite valid if 
they are null, but I want to do other things if they aren't, and I don't 
want to cast constantly.



More information about the Digitalmars-d mailing list