ref, safety, and warnings

Peter Alexander peter.alexander.au at gmail.com
Sun Sep 23 12:19:12 PDT 2012


On Sunday, 23 September 2012 at 18:43:08 UTC, bearophile wrote:
>> foreach (idx, val; arr)
>> {
>>    val.x = idx;  // clearly a bug, but lacks warning
>> }
>>
>> I've had *numerous* occasions over the last few years where 
>> I've had this bug happen to me.
>
> The same for me. Most people seem to not care for this problem, 
> I
> don't understand why. But I think it's a common source for bugs
> in D programs. D design must take in account not just 
> error-prone
> features inherited from C, but also to avoid bug-prone 
> situations
> created by D-specific features.

Me too. I think this is the most common bug in my programs caused 
by the language.


More information about the Digitalmars-d mailing list