Struct with default ctor (Was: [dmd-beta] dmd 2.064 beta take 2)
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sun May 19 06:08:53 PDT 2013
On 5/19/13 8:55 AM, deadalnix wrote:
> On Sunday, 19 May 2013 at 12:06:01 UTC, Simen Kjaeraas wrote:
>> My experience is the complete opposite - I think maybe 20% of bugs at
>> my job
>> are caused by null references. But as you say, they are very easily
>> fixed.
>>
>
> Sometime they are super freaking hard. I have a horror story debugging
> Apache Cayenne : http://cayenne.apache.org/ because it was throwing NPE
> on a race condition that would never show up once the code is instrumented.
>
> A reference was null for a short moment and then set to something. Due
> to concurrency, in extreme cases it could be seen as null where it was
> assumed everywhere to be set.
Sounds like a race problem unrelated to null. With non-null objects the
race would have manifested itself in a different way, perhaps even more
pernicious.
Anyhow, this discussion should have finality. We could go on forever
arguing the usefulness or lack thereof of non-nullable references. They
didn't catch up in some languages and did in some. My personal opinion
is "nice to have, but not greatly compelling".
It's reasonable to assume no major language changes will accommodate
non-null references, so the next best thing would be to focus on a
library solution. As Walter said, a library solution has the perk of
allowing other interesting restricted types.
Andrei
More information about the Digitalmars-d
mailing list