Automatic Foreach

Knud Soerensen 4tuu4k002 at sneakemail.com
Sun Apr 27 04:13:53 PDT 2008


Have a look at the vectorization suggestion
http://all-technology.com/eigenpolls/dwishlist/index.php?it=10
on the wish list.
http://all-technology.com/eigenpolls/dwishlist/

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.
> 

> Rantional:
> Half the time I create a for loop I endup encapsulating it in a
> function.  If D automatically created the function it would be one less
> thing to worry about.  If I need specialize behavior I could always
> specialize the function later by providing an overload.
> 
if you encapsulating the loop in the function
you get 1 functions call and N loop-body executions
but if you let d loop the function you get N function calls and N body
excutions.
You are adding N-1 extra function calls !

Knud




More information about the Digitalmars-d mailing list