Opt-in non-null class references?

SimonN eiderdaus at gmail.com
Wed Feb 28 15:25:40 UTC 2018


On Wednesday, 28 February 2018 at 14:05:19 UTC, Jonathan M Davis 
wrote:
> I expect that pretty much anything you propose that requires 
> code flow analysis is DOA.
> Walter was arguing against precisely because code-flow analysis 
> is so hard to get right,

Thanks, that's an important judgement. I've read the 3 threads 
that I found around this issue, but didn't notice this sentiment 
before that code-flow analysis is so problematic.

Yeah, non-null class fields hinge on code-flow analysis. And I'll 
accept that pushing non-null refs won't lead to anything if the 
necessary code-flow analysis is too tricky for the benefit.

> I've never understood why some folks have so many problems with 
> null pointers.

My gripe is that the necessarily-nullable class reference doesn't 
express the intent.
Either a codebase must rely on silent conventions or every 
function with asserts.

> and that blows up quite quickly such that it's fixed quite 
> quickly.

Yeah, I admit that most null crashes surface adequately quickly 
even when you have to run the program first.

It's merely sad to see D, with all its powerful static 
inspection, rely on runtime tests for nulls while other languages 
(Kotlin, Zig, and 2017 C#) rule null out at compile-time, as if 
it's the most natural thing in the world.

-- Simon


More information about the Digitalmars-d mailing list