Other notes

Moritz Warning oh at no.es
Sat Nov 24 17:56:51 PST 2007


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. ;-)



More information about the Digitalmars-d mailing list