Why does nobody seem to think that `null` is a serious problem in D?
Atila Neves
atila.neves at gmail.com
Fri Nov 30 12:01:50 UTC 2018
On Friday, 30 November 2018 at 06:15:29 UTC, O-N-S (ozan) wrote:
> On Monday, 19 November 2018 at 21:23:31
> On Monday, 19 November 2018 at 21:23:31 UTC, Jordi Gutiérrez
> Hermoso wrote:
>>
>> I'm not the only one who has done this. I can't find it right
>> now, but I've seen at least one person open a bug report
>> because they misunderstood this as a bug in dmd.
>>
>> I have been told a couple of times that this isn't something
>> that needs to be patched in the language, but I don't
>> understand. It seems like a very easy way to generate a
>> segfault (and not a NullPointerException or whatever).
>>
>
> I love Null in an empty class variable and I use it very often
> in my code. It simplifies a lot.
>
> What would be a better way? (practical not theoretical)
>
> Regards Ozan
A better way is to always initialise.
Invalid states should be unrepresentable.
More information about the Digitalmars-d-learn
mailing list