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

aliak something at something.com
Tue Nov 20 07:08:33 UTC 2018


On Tuesday, 20 November 2018 at 00:30:44 UTC, Jordi Gutiérrez 
Hermoso wrote:
> On Monday, 19 November 2018 at 21:57:11 UTC, Neia Neutuladh 
> wrote:
>
>> [...]
>
> What do you think about making the syntax slightly more 
> explicit and warn or possibly error out if you don't do it that 
> way? Either
>
>   SomeClass c = null;
>
> or
>
>   SomeClass c = new SomeClass();
>
> and nothing else.
>
>> [...]
>
> Nulls/Nones are always a big gap in a language's type system. A 
> common alternative is to have some Option/Maybe type like Rust 
> or Haskell or D's Variant. How about making that required to 
> plug the null gap?

You can give optional (https://code.dlang.org/packages/optional) 
a try and see if that works for you.




More information about the Digitalmars-d-learn mailing list