[Swift-devel] Problem with iterate
    Mihael Hategan 
    hategan at mcs.anl.gov
       
    Sat Feb 20 13:55:34 CST 2010
    
    
  
On Sat, 2010-02-20 at 19:27 +0000, Ben Clifford wrote:
> > 
> > > So what would that do to SwiftScript? Well you could get rid of any 
> > > partial assignment to arrays and say the equivalent of:
> > 
> > I think that convergence loops (i.e. "do this repeatedly until some
> > non-trivial condition becomes true") would not be possible then unless
> > recursion was used.
> 
> I was imagining having a high level construct to replace "iterate" that 
> looks quite like iterate but is more restricted in its use eg takes a 
> some (laststate -> newstate) operation (the iterate body now) and takes 
> some (newstate -> boolean) operation (the until clause now).
That would probably be better for most cases. Though I'm not sure how
exactly this would be expressed.
I think, in a sense, the choice of foreach (and array indices) instead
of map (and lists) was due to a desire to make this close to C because
of the belief that our target audience would then have an easier time
adapting to it.
Which is funny because the non-restrictive nature of C is, I think, what
makes it easy to write the wrong program which is what you are trying to
get rid of.
> 
> Having provided that construct as part of SwiftScript, you wouldn't need 
> recursion.
Right. Loops and recursion are equivalent.
> 
> Thats a way to do things that keeps it fairly like it is now. A further 
> departure from where it is now is to say "well it should be a proper 
> language, and recursion shouldn't hurt".
> 
    
    
More information about the Swift-devel
mailing list