Automatic Foreach

Edward Diener eddielee_no_spam_here at tropicsoft.com
Sun Apr 27 06:52:46 PDT 2008


janderson wrote:
> I know Walter has his head stuck in Const/Invarient/Pure multithreading 
> land at the moment.  I thought I'd fire off this interesting proposal 
> anyway.
> 
> This is a follow up proposal/suggestion to one I sent a while back.  I 
> hope to flesh it out a bit more.
> 
> The idea is to automatically generate for loops for arrays that are used 
> as parameters.  It will reduces type safety in one area but makes the 
> language more expressive, particularly for templates.
> 
> Basically:
> 
> void foo(char c)
> {
>  ...
> }
> 
> ...
> 
> char[] array;
> 
> ...
> 
> This part:
> 
> foreach(auto value; array)
> {
>   foo(array);
> }

foreach(auto value; array)
{
     foo(value);
}

> 
> becomes:
> 
> foo(array);



More information about the Digitalmars-d mailing list