Other notes

David B. Held dheld at codelogicconsulting.com
Sat Nov 24 18:51:04 PST 2007


Moritz Warning wrote:
> Moritz Warning Wrote:
> 
>> bearophile Wrote:
> 
>>> 3b) This D code lacks a ref, maybe the compiler can spot this bug (I have done a mistake like this in the past):
>>>
>>> int[10] array;
>>> foreach(i, el; array)
>>>     el = i;
>> int[10] array;
>> foreach(i, inout el; array)
>>     el = i;
>>
>> Works. :)
> Well.. I guess it's hard to spot for the compiler that there could be an error.
> What if you want to just some stupid benchmarking?
> The decision if this does or does not have an effect (and therefore would be an error) may be a subject of a boring discussion. ;-)

I use the iteration variable as a temporary sometimes.  I would be 
annoyed if the compiler tried to 'detect' that for me.

Dave



More information about the Digitalmars-d mailing list