Null references (oh no, not again!)

Jason House jason.james.house at gmail.com
Wed Mar 4 18:09:25 PST 2009


Walter Bright Wrote:

> Andrei Alexandrescu wrote:
> > Walter Bright wrote:
> >> Ary Borenszweig wrote:
> >>> It's not like that. They don't require you to initialize a variable 
> >>> in it's initializer, but just before you read it for the fist time. 
> >>> That's very different.
> >>
> >> The only way to do that 100% reliably is to instrument the running code.
> > 
> > Doing it conservatively still is 100% reliable but has the user 
> > occasionally add code that's not needed.
> 
> That:
> 
> 1. still has the user adding dead code

I'll gladly add assert(0) if my complex logic confuses the compiler. Actually, it pisses me off when the current dmd compiler complains about an assert(0) being unreachable.

 
> 2. will generate endless bug reports (*) on why sometimes the compiler 
> asks for an initialization and sometimes it doesn't

IMHO, this type of thing is easy to understand. Huge (recurring) threads like this one are a sign of a bigger language issue than ill-informed bug reports.
 
> 3. (2) will behave in an implementation dependent manner, depending on 
> how thorough the flow analysis is, making for non-portable source code

I think the only way to do this is to define simplistic flow analysis in the spec and then stick to it. Afterall complex flow can confuse humans reading the code too.

> P.S. I've been doing tech support for compilers for 25 years, and I wish 
> to reduce the workload by designing out things that confuse people!




More information about the Digitalmars-d mailing list