User Defined Attributes

Walter Bright newshound2 at digitalmars.com
Tue Nov 6 10:09:39 PST 2012


On 11/6/2012 9:52 AM, bearophile wrote:
> // Case3 (uncommon)
> void main() {
>      auto data = [0, 1, 2, 3];
>      foreach (@copy x; data)
>          writeln(++x);
> }

x is a value type, and it is already copied. And if you did want to copy it,

     foreach (x; data)
     {   auto copy = x;
         writeln(++copy);
     }

I don't see what the annotation buys you, even if it could be made to work.



More information about the Digitalmars-d-announce mailing list