Opt-in non-null class references?

Atila Neves atila.neves at gmail.com
Wed Feb 28 16:14:09 UTC 2018


On Wednesday, 28 February 2018 at 14:05:19 UTC, Jonathan M Davis 
wrote:
> On Wednesday, February 28, 2018 13:43:37 SimonN via 
> Digitalmars-d wrote:
>> [...]
>
> I expect that pretty much anything you propose that requires 
> code flow analysis is DOA. Walter is almost always against 
> features that require it, because it's so hard to get right, 
> and the places that D does use it tend to have problems (e.g. 
> it's actually quite trivial to use a const or immutable member 
> variable before it's initialized). In fact, IIRC, in the most 
> recent discussion on having the compiler give an error when it 
> can detect that a null pointer or reference is being 
> dereferenced, Walter was arguing against precisely because 
> code-flow analysis is so hard to get right, and encoding it in 
> the spec is particularly bad (which would be required for 
> anything involving errors). If non-nullable references were 
> added to D, I expect that they would have to be like structs 
> marked with
>
> [...]

I don't understand the problems with null either - my program 
segfaults, I look at the core dump and initialise whatever it is 
that was T.init. And this in the rare case I actually use a 
pointer or a class instance to begin with.

I also declare nearly every variable with `const var = <expr>;`, 
so I guess that makes it even more unlikely for me.

Atila


More information about the Digitalmars-d mailing list