[Swift-devel] Problem with iterate

Mihael Hategan hategan at mcs.anl.gov
Sat Feb 20 14:28:45 CST 2010


On Sat, 2010-02-20 at 20:10 +0000, Ben Clifford wrote:
> > That would probably be better for most cases. Though I'm not sure how
> > exactly this would be expressed.
> 
> If you're trying to keep syntax that looks vaguely like foreach and 
> iterate now, I'm not sure what either would look like...
> 
> When I implemented iterate I toyed with the idea of having magic variables 
> called old and new that you could access, like this:
> 
> iterate {
>   new = f(old)
> } until(checkwonderful(new))
> 

Is that better than asserting in documentation that old === a[i] and new
=== a[i + 1]? Does it prevent a user somehow from writing other funny
stuff in the body of iterate (the syntax doesn't suggest so)?





More information about the Swift-devel mailing list