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

Ben Clifford benc at hawaga.org.uk
Fri Feb 19 11:54:28 CST 2010


A point of information related to this discussion:

Underordered single assignment doesn't necessarily lead to deadlock in 
general. Using Haskell, and making this mutually recursive definition of x 
and y.

f l = 1 : l     -- if you like lisp,  1:l means (cons 1 l)

x = f y
y = f x

main = print x

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

Also in Haskell, if you substitute in this,

f l = if length l < 200 then 1 : l else l

then Haskell detects a loop at runtime (not compile time) - that's pretty 
much the kind of "deadlock detection" that we're talking about here.

$ ./example2 
example2: <<loop>>

(or indeed anything involving the use of 'length l' I think)

It might be reasonable to not attempt to do something in this space if ghc 
cannot do it.

Now whats different between the above example and swiftscript? well, I 
used lists which is a data type that Swift doesn't have. Though maybe its 
possible to make something like this using arrays/structs somehow.

-- 
http://www.hawaga.org.uk/ben/




More information about the Swift-user mailing list