Null references (oh no, not again!)

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Mar 4 18:35:33 PST 2009


Jason House wrote:
> 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!
> 

I agree with Jason that it's relatively easy to define properly the 
behavior of a flow-informed feature. I also agree with bearophile (I 
think) about the fact that flow analyses are the norm in today's modern 
languages (C#, Java, Scala, not to mention the more advanced ones). D is 
behind in that regard. I also agree with Walter that he has a rather 
overflowing plate already and he instinctively starts with disagreeing 
with something that has him do more work.


Andrei



More information about the Digitalmars-d mailing list