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

12345swordy alexanderheistermann at gmail.com
Fri Nov 30 15:32:55 UTC 2018


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:
>>> When I was first playing with D, I managed to create a 
>>> segfault
>>
>>> What's the reasoning for allowing this?
>>
>> 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();


More information about the Digitalmars-d-learn mailing list