[Swift-devel] Swift user guide

Ian Foster foster at uchicago.edu
Sun Mar 1 23:25:11 CST 2009


Reading a recent email about "iterate" got me looking at the Swift  
manual. This is looking very nice. I had a couple of comments:

1) "Conceptually, a parallel can be drawn between Swift mapped  
variables and Java reference types. In both cases there is no  
syntactic distinction between primitive types and mapped types or  
reference types respectively. Additionally, the semantic distinction  
is also kept to a minimum."

--> I don't think we should assume that readers know what a Java  
reference type is. Most will not.

2) Arrays: I gather from below that the size of an array is defined by  
assignments to it. This seems confusing and dangerous to me: doesn't  
it require a global analysis, which must ultimately be undecidable, to  
determine whether an array is closed?

Statements which deal with the array as a whole will often wait for  
the array to be closed before executing (thus, a closed array is the  
equivalent of a non-array type being assigned). However, a foreach  
statement will apply its body to elements of an array as they become  
known. It will not wait until the array is closed.

Consider this script:

file a[];
file b[];
foreach v,i in a {
   b[i] = p(v);
}
a[0] = r();
a[1] = s();

Initially, the foreach statement will have nothing to execute, as the  
array a has not been assigned any values. The procedures r and s will  
execute. As soon as either of them is finished, the corresponding  
invocation of procedure p will occur. After both r and s have  
completed, the array a will be closed since no other statements in the  
script make an assignment toa.



3) In the following text, the (,index) is presumably meant to indicate  
an optional element. But as you don't use a different font, or indeed  
have indicated what conventions you are using, readers may not realize  
that.



foreach statements have the general form:

foreach controlvariable (,index) in expression {
     statements
} 
  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/swift-devel/attachments/20090301/0a1d9912/attachment.html>


More information about the Swift-devel mailing list