[Swift-commit] r6615 - in branches/faster: . docs/cookbook docs/userguide

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Mon Jul 8 01:17:52 CDT 2013


Author: hategan
Date: 2013-07-08 01:17:51 -0500 (Mon, 08 Jul 2013)
New Revision: 6615

Modified:
   branches/faster/
   branches/faster/docs/cookbook/coasters
   branches/faster/docs/userguide/app_procedures
   branches/faster/docs/userguide/language
Log:
merged 6256-6258 from trunk


Property changes on: branches/faster
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/release-0.93:4761-5122
/trunk:6172,6177,6182,6189-6190,6202-6203,6206-6208,6215-6223,6231-6241,6255
   + /branches/release-0.93:4761-5122
/trunk:6172,6177,6182,6189-6190,6202-6203,6206-6208,6215-6223,6231-6241,6255-6258

Modified: branches/faster/docs/cookbook/coasters
===================================================================
--- branches/faster/docs/cookbook/coasters	2013-07-08 06:15:10 UTC (rev 6614)
+++ branches/faster/docs/cookbook/coasters	2013-07-08 06:17:51 UTC (rev 6615)
@@ -1,8 +1,8 @@
 Coasters
 --------
 Coasters were introduced in Swift v0.6 as an experimental feature. In many
-applications, Swift performance can be greatly enhanced by the use of CoG
-coasters. CoG coasters provide a low-overhead job submission and file transfer
+applications, Swift performance can be greatly enhanced by the use of
+coasters. Coasters provide a low-overhead job submission and file transfer
 mechanism suited for the execution of short jobs (on the order of a few
 seconds). A detailed information on coasters can be found at http://www.ci.uchicago.edu/swift/guides/userguide.php#coasters.
 //**Include neat diagrams.**

Modified: branches/faster/docs/userguide/app_procedures
===================================================================
--- branches/faster/docs/userguide/app_procedures	2013-07-08 06:15:10 UTC (rev 6614)
+++ branches/faster/docs/userguide/app_procedures	2013-07-08 06:17:51 UTC (rev 6615)
@@ -432,27 +432,46 @@
 
 readData
 ~~~~~~~~
-readData will read data from a specified file.
+readData will read data from a specified file and assign it to Swift variable. The format of the input file is
+controlled by the type of the return value. For scalar return types, such as
+int, the specified file should contain a single value of that type. For arrays
+of scalars, the specified file should contain one value per line.  For complex types
+of scalars, the file should contain two rows. The first row should be structure
+member names separated by whitespace. The second row should be the
+corresponding values for each structure member, separated by whitespace, in the
+same order as the header row.  For arrays of structs, the file should contain a
+heading row listing structure member names separated by whitespace. There
+should be one row for each element of the array, with structure member elements
+listed in the same order as the header row and separated by whitespace. The following example shows how readData() can be used to populate an array of Swift struct-like complex type:
 
-The format of the input file is controlled by the type of the return value.
+----
+type Employee{
+    string name;
+    int id;
+    string loc;
+}
 
-For scalar return types, such as int, the specified file should contain
-a single value of that type.
+Employee emps[] = readData("emps.txt");
+----
 
-For arrays of scalars, the specified file should contain one value per
-line.
+Where the contents of the "emps.txt" file are:
 
-For structs of scalars, the file should contain two rows. The first row
-should be structure member names separated by whitespace. The second row
-should be the corresponding values for each structure member, separated
-by whitespace, in the same order as the header row.
+----
+name id address
+Thomas 2222 Chicago
+Gina 3333 Boston
+Anne 4444 Houston
+----
 
-For arrays of structs, the file should contain a heading row listing
-structure member names separated by whitespace. There should be one row
-for each element of the array, with structure member elements listed in
-the same order as the header row and separated by whitespace. (since
-Swift 0.4)
+This will result in the array "emps" with 3 members. This can be processed within a Swift script using the foreach construct as follows:
 
+----
+foreach emp in emps{
+    tracef("Employee %s lives in %s and has id %d", emp.name, emp.loc, emp.id);
+}
+----
+
+
 readStructured
 ~~~~~~~~~~~~~~
 readStructured will read data from a specified file, like readdata, but

Modified: branches/faster/docs/userguide/language
===================================================================
--- branches/faster/docs/userguide/language	2013-07-08 06:15:10 UTC (rev 6614)
+++ branches/faster/docs/userguide/language	2013-07-08 06:17:51 UTC (rev 6615)
@@ -11,20 +11,52 @@
 variables. The syntax superficially resembles C and Java. For example,
 { and } characters are used to enclose blocks of statements.
 
-Types in Swift can be atomic or composite. An atomic type can be
-either a primitive type or a mapped type. Swift provides a fixed set
-of primitive types, such as integer and string. A mapped type
-indicates that the actual data does not reside in CPU addressable memory
-(as it would in conventional programming languages), but in POSIX-like
-files. Composite types are further subdivided into structures and
-arrays. Structures are similar in most respects to structure types in
-other languages. Arrays use numeric indices, but are sparse. They can
-contain elements of any type, including other array types, but all
-elements in an array must be of the same type. We often refer to
+Types in Swift can be atomic or composite. An atomic type can be either a
+primitive type or a mapped type. Swift provides a fixed set of primitive types,
+such as integer and string. A mapped type indicates that the actual data does
+not reside in CPU addressable memory (as it would in conventional programming
+languages), but in POSIX-like files. Composite types are further subdivided
+into structures and arrays. Structures are similar in most respects to
+structure types in other languages. In Swift, structures are defined using the
+_type_ keyword (there is no struct keyword). Arrays use numeric indices, but
+are sparse. They can contain elements of any type, including other array types,
+but all elements in an array must be of the same type. We often refer to
 instances of composites of mapped types as datasets.
 
 image:type-hierarchy.png[]
 
+Atomic types such as string, int, float and double work the same way as in
+C-like programming languages. A variable of such atomic types can be defined as
+follows:
+
+----
+string astring = "hello";
+----
+
+A struct variable is defined using the _type_ keyword as discussed above.
+Following is an example of a variable holding employee data:
+
+----
+type Employee{
+    string name;
+    int id;
+    string loc;
+}
+----
+
+The members of the structure defined above can be accessed using the dot
+notation. An example of a variable of type Employee is as follows:
+
+----
+Employee emp;
+emp.name="Thomas";
+emp.id=2222;
+emp.loc="Chicago";
+----
+
+Arrays of structures are allowed in Swift. A convenient way of populating
+structures and arrays of structures is to use the _readData()_ function.
+
 Mapped type and composite type variable declarations can be annotated
 with a mapping descriptor indicating the file(s) that make up that
 dataset. For example, the following line declares a variable named
@@ -114,8 +146,14 @@
 Arrays and Parallel Execution
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-Arrays of values can be declared using the [] suffix. An array be
-mapped to a collection of files, one element per file, by using a
+Arrays of values can be declared using the [] suffix. Following is an example
+of an array of strings:
+
+----
+string pets[] = ["shane", "noddy", "leo"];
+----
+
+An array may be mapped to a collection of files, one element per file, by using a
 different form of mapping expression. For example, the filesys_mapper 
 maps all files matching a particular unix glob pattern into an array:
 




More information about the Swift-commit mailing list