[Swift-devel] problems with external dependencies

Michael Wilde wilde at mcs.anl.gov
Tue Mar 24 09:02:44 CDT 2009


...a digression for better understanding the language:

On 3/24/09 8:15 AM, Ben Clifford wrote:
> On Tue, 24 Mar 2009, Michael Wilde wrote:
> 
>> Back to the main point: I need to dissect this example to better understand
>> how it lets me wait for all the apps to finish without putting an external var
>> on each one, and hence avoids the array of externals. This violates my (most
>> recent) understanding of procedure return, in that generate() would return to
>> the calls *before* all the ls() procs called from its foreach loop returns.
>> That seems to be the crux of the matter.
> 
> no, they return when everything in them has finished executing.

That makes more sense - it was my *initial* understanding. Some 
mis-interpretation of info from a prior email thread led me astray into 
thinking that proc return was somehow magically more asynchronous. This 
helps return some comforting simplicity to my mental model.

So no matter how many parallel procedure calls a procedure triggers, 
directly or indirectly, through multiple levels of calls, the procedure 
does not return until all the calls below it on the stack have returned. 
  is that correct?

Is it technically the same for the foreach(), and in fact for every 
other statement (eg, if() ) - that each statement essentially starts a 
"block" that may invoke parallel procs, and again, each statement waits 
for its child statements and procs to complete before it completes?

> Thats how the unpleasant hack of putting foreach loops inside a procedure 
> to get closing to happen at the end of the foreach happens. Its the same 
> here - the external variable is closed when everything inside its 
> returning procedure is finished.

Is it further true that the term "closing" applies to all vars, of all 
types, whether atomic or compound? Where "closed" is the same as "set" 
for atomic vars? And that:
- the "setting" of external type vars is tied to the procedure that 
*returns* them?
- the "setting" of other atomic vars happens when they are assigned a 
value in an assignment statement.
- the setting of arrays is based on flow analysis (as per below, from a 
prior thread)
- the setting of structures is ??? (when all fields are set or when that 
structure goes out of scope?
- the setting of file vars means that the file has been created by an 
app. The var contains only a mapping (which is set before the file is 
created) and a state, set/unset, somewhat like externals. So externals 
are almost? exactly like file vars, but have no mapping?

 From an earlier thread on array closing, by Ben:

"...there is static analysis of source code, and when no
more assignments are left to make to an array, its regarded as closed.

However, in the case of multidimensional arrays, this only happens when
the entire top level array has no more assignments at all, not as each
subarray happens to become finished."






More information about the Swift-devel mailing list