null [re: spec#]

Nick Sabalausky a at a.a
Tue Nov 9 11:10:39 PST 2010


"Nick Sabalausky" <a at a.a> wrote in message 
news:ibc5ve$1q75$1 at digitalmars.com...
> "Simen kjaeraas" <simen.kjaras at gmail.com> wrote in message 
> news:op.vlwul8tuvxi10f at biotronic-pc.lan...
>>
>> Yup. Also, as opposed to certain other solutions, it does not require
>> advanced flow control, that is likely to be incomplete. Incomplete flow
>> control here will make people write code 'to shut the compiler up'. And
>> that is worse than uninitialized variables.
>>
>
> First of all, the risks from "shut the compiler up" initalizations are 
> highly exagerated (I've dealt with enough C# to know that Walter's full of 
> crap on the "dangers" of that). Secondly, there is absolutely no way it's 
> worse than auto-initing. Let's look at an example:
>
> int i;
> // Dumb-ass convoluted code that should never pass code review anyway:
> if(m)
>    i = something;
> // Stuff here
> if(m)
>    // Do something with 'i'
>

Also, as I've said when this was discussed in the past, I wouldn't even want 
the flow analysis to be perfect because all that would accomplish is to 
encourage garbage like the above (which would just end up being highly 
fragile anway).


> Suppose the compiler complains 'i' might be used before being written to. 
> The programmer has two choices:
>
> 1. Blindly toss in "=0" with no regard as to whether or not it's correct.
> 2. Fix the damn code properly (And believe it or not, this *may* actually 
> amount to "int i=0;", but just not always).
>
> Now, let's go back to D's current behavior. Only one thing ever happens 
> now. The compiler will:
>
> 1. Blindly toss in "=0" with no regard as to whether or not it's correct.
>
> Note that's word-for-word identical to before, except now option 2, the 
> *right* option, doesn't even fucking exist. That does NOT make it better, 
> that makes it worse.
>
> 




More information about the Digitalmars-d mailing list