Null references redux

bearophile bearophileHUGS at lycos.com
Sat Sep 26 19:45:35 PDT 2009


Andrei Alexandrescu:

> The problem is you keep on insisting on one case "I have a non-null 
> reference that I don't have an initializer for, but the compiler forces 
> me to find one, so I'll just throw a crappy value in." This focus on one 
> situation comes straight with your admitted bad habit of defining 
> variables in one place and initializing in another.

Thank you Andrei for your good efforts in trying to add some light on this topic. I think we are converging :-)

But I think you have to deal with the example shown by Jeremie Pelletier too, this was my answer:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=96834

(What I have written in the last line is confused. I meant that the type system doesn't allow you to read or access an object before it's initialized. This looks like flow analysis, but there are ways to simplify/constraint the situation enough, for example with that enforce scope block).

Bye,
bearophile



More information about the Digitalmars-d mailing list