Why does nobody seem to think that `null` is a serious problem in D?

12345swordy alexanderheistermann at gmail.com
Fri Nov 30 15:39:05 UTC 2018


On Friday, 30 November 2018 at 15:32:55 UTC, 12345swordy wrote:
> On Friday, 30 November 2018 at 12:00:46 UTC, Atila Neves wrote:
>> On Thursday, 29 November 2018 at 18:31:41 UTC, SimonN wrote:
>>> On Monday, 19 November 2018 at 21:23:31 UTC, Jordi Gutiérrez 
>>> Hermoso wrote:
>>>> [...]
>>>
>>>> [...]
>>>
>>> 100 % agree that there should be non-nullable class 
>>> references, they're my main missing feature in D. Likewise, 
>>> I'm astonished that only few D users wish for them.
>>
>> https://github.com/aliak00/optional/blob/master/source/optional/notnull.d
>>
>> "But I don't like the verbosity!"
>>
>> alias MyClass = NotNullable!MyClassImpl;
>
> Huh neat, though it would nice to allow conversion of Nullable 
> to NotNullable via runtime conditional checking.
>
> NotNullable!MyClassImpl = (MyClassImpvar != Null) ? 
> MyClassImpvar : new MyClassImpvar();
I meant new MyClassImp(), but you get the idea.


More information about the Digitalmars-d-learn mailing list