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

Ben Clifford benc at hawaga.org.uk
Sat Feb 20 04:17:39 CST 2010


> > x and y are both infinite lists [1,1,1,1,1,1,1,1,1,1,1,1,1,...] (so 
> > running the above code prints out a never-ending (until ctrl-c) list of 
> > 1,1,1,1,...)
> 
> What difference does that make? To the outside observer both programs
> hang.

the print in the original hangs.

print (take 5 x)

doesn't hang, despite the fact that x is an infinite list. It prints 
[1,1,1,1,1]

My point basically is that there are some safe uses of cyclic definitions, 
in languages that although different bear some strong similarity to 
SwiftScript. It might be that this applies to SwiftScript too or it might 
be sufficiently different (eg in data structures and in evaluation 
semantics) that it doesn't apply.

-- 



More information about the Swift-user mailing list