Why does nobody seem to think that `null` is a serious problem in D?
Stefan Koch
uplink.coder at googlemail.com
Wed Nov 21 17:11:23 UTC 2018
On Wednesday, 21 November 2018 at 10:47:35 UTC, NoMoreBugs wrote:
> 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.
For _TRIVIAL_cases this is not hard.
But we cannot only worry about trivial cases;
We have to consider _all_ cases.
Therefore we better not emit an error in a trivial case.
Which could lead users to assume that we are detecting all the
cases.
That in turn will give the impression of an unreliable system,
and indeed that impression would not be too far from the truth.
More information about the Digitalmars-d-learn
mailing list