[Swift-devel] playing with array closing.

Mihael Hategan hategan at mcs.anl.gov
Tue Nov 20 09:44:27 CST 2007


On Tue, 2007-11-20 at 06:54 +0000, Ben Clifford wrote:
> 
> 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.

I thought you can reorder them, but it may be difficult if a single
statement writes to multiple arrays (such as the foreach).

> 
> > 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