It sounds like Mihael and I agree, but maybe I should explain the reasoning for others' benefit. I think that this example is one where the serial imperative interpretation vs. dataflow interpretation actually are completely different so people probably have different intuitions about what it should do. I think this has been a source of confusion since users of Swift
frequently understand their scripts by tracing the execution step by
step as you would an imperative language, which actually works 90% of
the time.<br><br>The functional/dataflow interpretation rests on the idea that A refers to a single value, the complete contents of the array after closing. So f(A) always means f applied to the final value of A.<br><br>
There are a couple of reasons that Swift/T goes with dataflow interpretation over the serial interpretation: <br><ul><li>It makes guaranteeing determinism much simpler</li><li>It means that there are no problems with executing the iterations of the loop in parallel independently (this is especially important for Swift/T)<br>
</li></ul>I guess this is a bit confusing for some users but I think that the behaviour is reasonable and consistent. I'm not sure if there a way to help users with potentially counter-intuitive behaviour, like a compiler warning - aside from maybe documenting and explaining it better.<br>
<br>- Tim<br><br><div class="gmail_quote">On Wed, Nov 21, 2012 at 11:32 PM, Mihael Hategan <span dir="ltr"><<a href="mailto:hategan@mcs.anl.gov" target="_blank">hategan@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Wed, 2012-11-21 at 18:36 -0800, Mihael Hategan wrote:<br>
[...]<br>
<div class="im">> ><br>
> > foreach i in [0:10] {<br>
> > a[i] = 1;<br>
> > f(a);<br>
> > }<br>
><br>
> It shouldn't deadlock. Nothing should. It just does in the current<br>
> swift/k implementation.<br>
><br>
> ><br>
> > In Swift/T it does the same thing as:<br>
> > foreach i in [0:10] {<br>
> > a[i] = 1;<br>
> > }<br>
> > foreach i in [0:10] {<br>
> > f(a);<br>
> > }<br>
><br>
> I don't know if I'd expect that if I wrote that code. Another<br>
> possibility is that I want f to be invoked successively with [1], [1,<br>
> 1], [1, 1, 1], etc. So I don't think it's obvious what that code should<br>
> do, and I'd be inclined to have it forbidden. If the required behaviour<br>
> is f([10x1]) ten times, then the user can state that explicitly by<br>
> writing the equivalent code you mention.<br>
<br>
</div>I would like to revise my statement. I agree with your proposed solution<br>
from a dataflow perspective (which I lost there for a bit). When<br>
invoking f(a) you are saying run f with some array as argument and the<br>
issue of where that array is built is not relevant.<br>
<span class="HOEnZb"><font color="#888888"><br>
Mihael<br>
<br>
</font></span></blockquote></div><br>