Automatic Foreach
    janderson 
    askme at me.com
       
    Sun Apr 27 01:18:08 PDT 2008
    
    
  
Janice Caron wrote:
> 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.
This raises an interesting point.  So the typesaftly issue could be 
solved like:
foo(array[]);
-Joel
    
    
More information about the Digitalmars-d
mailing list