[Swift-user] Re: [Swift-devel] Problem with iterate

Michael Wilde wilde at mcs.anl.gov
Wed Feb 17 11:05:21 CST 2010


An example of the "if 0" approach, Tibi:

   iterate r {
      if ( r==0 ) {
         pdata[0] = ItFixInit(p);
      }
      else {
         sim[r] = doRound(p, nsim, config, "runoops");
         (pdata[r], converged[r]) = analyze(sim[r], pdata[r-1], r, maxr);
      }
   } until ( r==maxr );

Ben, thanks for the suggested fix.

- Mike

----- "Ben Clifford" <benc at hawaga.org.uk> wrote:

> > I have put together this really simple iteration example, which I
> expected
> > to work (and it used to work in the past):
> 
> mmm.
> 
> yeah, the static analysis of when array elements are allowed to be 
> assigned doesn't work well there.
> 
> If anyone is looking at fixing it, I think its something like the
> iterate 
> statement being tagged as a writer of "all of statePathFiles", which
> then 
> conflicts with the first line being a partial writer of
> statePathFiles. 
> 
> If anyone is *really* look at fixing it, get rid of foreach and
> iterate 
> and put in proper dataflow based iteration (map, foldr, whatever) such
> 
> that arrays are single-assignment.
> 
> >         statePathFiles[0]=initFunc("hello");
> > 
> >         iterate it{
> >                 trace(@strcat("Iteration: ",it));
> >                 statePathFiles[it+1]=catFunc(statePathFiles[it]);
> >         } until (it==0);
> > }
> 
> > Please suggest  solutions for it .
> 
> probably the two solutions above are not what you're looking for.
> 
> but:
> 
> move the statePathFiles[0] assignment into the iterate loop, by saying
> 
> something like the below (but you'll have to adjust the array indices
> too, 
> I think, because you need to start one earlier now). something like
> this:
> 
> iterate it { 
>   if(it==0) {  statePathFiles[0]=initFunc("hello"); } else
>    {statePathFiles[it+1]=catFunc(statePathFiles[it]);}
>   } until(it==0);
> 
> 
> -- 
> _______________________________________________
> Swift-user mailing list
> Swift-user at ci.uchicago.edu
> http://mail.ci.uchicago.edu/mailman/listinfo/swift-user



More information about the Swift-user mailing list