Is the other-kind-of-null really necessary in Nullable and Variant?

deadalnix deadalnix at gmail.com
Mon Apr 29 09:14:01 PDT 2013


On Monday, 29 April 2013 at 16:02:11 UTC, Idan Arye wrote:
> On Monday, 29 April 2013 at 15:39:47 UTC, Simen Kjaeraas wrote:
>> On 2013-04-29, 17:34, Idan Arye wrote:
>>
>>> On Monday, 29 April 2013 at 12:23:04 UTC, deadalnix wrote:
>>>> On Sunday, 28 April 2013 at 16:33:19 UTC, Idan Arye wrote:
>>>>> When you use `std.typecons.Nullable` with a type that 
>>>>> already accept `null` values, you get two types of nulls - 
>>>>> the `Nullable`'s null state the the regular type's `null`:
>>>>>
>>>>>  Nullable!string a;
>>>>>  writeln(a.isNull()); //prints "true"
>>>>>  a = null;
>>>>>  writeln(a.isNull()); //prints "false"
>>>>>  a.nullify();
>>>>>  writeln(a.isNull()); //prints "true"
>>>>>
>>>>
>>>> All types should be non nullable. Problem solved.
>>>
>>> *All* types? Even object references and pointers?
>>
>> That would be nice, yes.
>
> And what would they be initialized to? When you write:
>     Object obj;
> what will `obj` refer to?
>
> Also, what about the C&C++ interface? Without null values, how 
> can you use an extern function that accepts or returns pointers?

Data flow analysis can smash your face if you try to use that 
before initializing it. In fact, this is already done in many 
languages.


More information about the Digitalmars-d mailing list