[Swift-devel] playing with array closing.

Ben Clifford benc at hawaga.org.uk
Tue Nov 20 00:54:37 CST 2007



On Tue, 20 Nov 2007, Mihael Hategan wrote:

> It may be ok to deal with array closing lexically instead of in a
> dataflow way. In other words close the array after the last lexical
> write (the scoping problem you mention still remains, but seems ok).
> This may simplify the implementation and have less memory overhead.

That's pretty much what this is. Lexical treatment at compile time. But I 
think there needs to be some runtime join of the various statements 
because they don't get executed (or rather, don't complete) in lexical 
order.

> The downside is that some corner cases may still break (e.g. calling
> listvals(array) from inside the foreach - though maybe that breaks
> anyway).

That works in what I did if the loop body doesn't also assign to the 
array. However, it has deadlock problems if the loop body both assigns to 
the array and reads from it.

With more complication at runtime, I think thats rectifiable - rather than 
partially-closing after the loop entirely finishes, should be possible to 
track which pieces of the inner loop have run and close after the 
appropriate statements have been run for each iteration.

-- 



More information about the Swift-devel mailing list