Automatic Foreach

Bill Baxter dnewsgroup at billbaxter.com
Sun Apr 27 00:54:50 PDT 2008


Janice Caron wrote:
> Something at the back of my mind tells me 

Maybe its the compiler error message that says "vector operations are 
not implemented" that's telling you that.  :-)  (as opposed to just 
plain "syntax error")

> 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