Automatic Foreach
Janice Caron
caron800 at googlemail.com
Sun Apr 27 00:27:28 PDT 2008
Something at the back of my mind tells me that, once upon a time,
Walter may have planned something like that for D, whereby
a[] = n;
a[] = b[];
a[] = b[] + c[];
a[] = f(b[]);
would mean
foreach(ref e;a) e = n;
foreach(i,ref e;a) e = b[i];
foreach(i,ref e;a) e = b[i] + c[i];
foreach(i,ref e;a) e = f(b[i]);
respectively. But if so, the plan got dropped a long time ago, and now
only the first two cases work.
(Disclaimer: I may have got that completely wrong).
I don't see the problem with the foreach version though. It's
certainly transparent.
More information about the Digitalmars-d
mailing list