[Swift-user] suggestion for program flow control
Ben Clifford
benc at hawaga.org.uk
Sat Nov 15 21:07:09 CST 2008
On Sat, 15 Nov 2008, Michael Wilde wrote:
> Any way to make the completion of doall() dependent on the completion of all
> the someapp() calls?
Try this. Represent the output of each separate call with a separate
'external'. Store them in an array. When the array is closed, things that
depend on that array can complete.
The code that you specify doesn't work because you can only use externals
as return values from application procedures, not from compound
procedures. (the semantics of returning from compound procedures are
poorly defined - I haven't thought about them much)
app (external o) a(int num) {
echo "first" num stdout="/dev/tty" ;
}
(external o[]) first() {
foreach i in [1:10] {
o[i]=a(i);
}
}
app b(external o[]) {
echo "second" stdout="/dev/tty";
}
external sync[] = first();
b(sync);
--
More information about the Swift-user
mailing list