(non)nullable types

Nick Sabalausky a at a.a
Sat Feb 14 11:36:52 PST 2009


"Christopher Wright" <dhasenan at gmail.com> wrote in message 
news:gn704j$2s2u$1 at digitalmars.com...
> 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.

You would only need to check when you're going to derefernce or convert to a 
non-nullable. Nulls could still be stored and passed around without 
checking. If this doesn't cover what you're concerned about, perhaps you 
could provide an example?





More information about the Digitalmars-d mailing list