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

NoMoreBugs NoMoreBugs at gmail.com
Wed Nov 21 10:47:35 UTC 2018


On Monday, 19 November 2018 at 21:39:22 UTC, Adam D. Ruppe wrote:
> On Monday, 19 November 2018 at 21:23:31 UTC, Jordi Gutiérrez 
> Hermoso wrote:
>> What's the reasoning for allowing this?
>
> The mistake is immediately obvious when you run the program, so 
> I just don't see it as a big deal. You lose a matter of 
> seconds, realize the mistake, and fix it.
>
> What is your proposal for handling it? The ones usually put 
> around are kinda a pain to use.

How hard would it be, really, for the compiler to determine that 
c was never assigned to, and produce a compile time error:

"c is never assigned to, and will always have its default value 
null"

That doesn't sound that hard to me.


More information about the Digitalmars-d-learn mailing list