[Swift-commit] r6375 - in trunk/docs: merged/refmanual userguide

ketan at ci.uchicago.edu ketan at ci.uchicago.edu
Tue Mar 12 15:32:38 CDT 2013


Author: ketan
Date: 2013-03-12 15:32:37 -0500 (Tue, 12 Mar 2013)
New Revision: 6375

Added:
   trunk/docs/merged/refmanual/build.sh
Modified:
   trunk/docs/merged/refmanual/swiftlang
   trunk/docs/userguide/mappers
Log:
switch case example

Added: trunk/docs/merged/refmanual/build.sh
===================================================================
--- trunk/docs/merged/refmanual/build.sh	                        (rev 0)
+++ trunk/docs/merged/refmanual/build.sh	2013-03-12 20:32:37 UTC (rev 6375)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+asciidoc --attribute stylesheet=${PWD}/swift.css swiftlang


Property changes on: trunk/docs/merged/refmanual/build.sh
___________________________________________________________________
Added: svn:executable
   + *

Modified: trunk/docs/merged/refmanual/swiftlang
===================================================================
--- trunk/docs/merged/refmanual/swiftlang	2013-03-12 19:20:37 UTC (rev 6374)
+++ trunk/docs/merged/refmanual/swiftlang	2013-03-12 20:32:37 UTC (rev 6375)
@@ -31,13 +31,22 @@
 +program.swift+, run:
 
 ----
-swift -sites.file sites.xml -config cf -tc.file tc program.swift
+swift -sites.file <sites.xml> -config <cf> -tc.file <tc.data> <program.swift>
 ----
 
 Swift accepts many commandline arguments. Following are the most frequently used:
 
-+-config <cf>+:: The config file
++-config <file>+ :: Indicates the Swift configuration file to be used for this
+run. Properties in this configuration file will override the default
+properties. If individual command line arguments are used for properties, they
+will override the contents of this file.
 
++-sites.file <file>+ :: Points to the location of the sites.xml file
+
++-tc.file <file>+ :: Points to the location of the tc.data file
+
++-resume <file>+ :: Resumes the execution using a log file
+
 == Program Structure
 
 Swift programs are composed of declaration of and calls to _composite_
@@ -148,7 +157,6 @@
 ** \v
 ** hexadecimal escape codes, e.g. \xf2
 
-
 The literals +true+ and +false+ may be used for boolean.
 
 ----
@@ -381,55 +389,8 @@
 [[argv]]
 ==== Command line
 
-Consider this command line:
+Swift accepts commandline arguments in the form of -var <value>. 
 
- turbine -l -n 3 program.tcl -v -a=file1.txt file2.txt --exec="prog thing1 thing2" --help file4.txt
-
-The arguments to +program.tcl+ are just the tokens after +program.tcl+
-
-+args() -> string+::
-
-Obtain all arguments as single string
-+
-E.g., +"-v -a=file1.txt file2.txt --exec="prog thing1 thing2" --help file4.txt"+
-
-The remaining functions are convenience functions oriented around
-Swift conventions.  Under these conventions, the example command above
-has _flagged_ arguments +v+, +a=file.txt+, +exec="prog thing1
-thing2"+, and +help+. The command has _unflagged_ arguments
-+file2.txt+ and +file4.txt+
-
-+argc()+::
-Get count of unflagged arguments
-
-+argv(string)+::
-_(argument-value)_
-Given a string, returns the flagged argument with that key:
-+
-+argv("a") -> file1.txt+
-
-+argp(int)+::
-_(argument-positional)_
-Given an integer, returns the unflagged argument at that index:
-+
-+argp(2) -> file4.txt+
-+
-Given 0, returns the program name,
-+
-+argp(0) -> /path/to/program.tcl+
-
-+argv_accept(string...)+::
-
-If program is given command line arguments not contained in given list,
-abort.
-E.g., +argv_accept("x")+ would cause program failure at run time
-
-+argv_contains(string) -> boolean+::
-
-Test if the command line contains the given flagged argument:
-+
-+argv_contains("v") -> true+
-
 ==== Debugging
 
  #include <assert.swift>
@@ -437,13 +398,6 @@
 +assert(boolean condition, string message)+::
 If condition is false, report +message+ and exit immediately.
 
-[[Turbine_information]]
-==== Turbine information
-
-+adlb_servers()    -> int+:: Number of ADLB servers
-+turbine_engines() -> int+:: Number of Turbine engines
-+turbine_workers() -> int+:: Number of Turbine workers
-
 === Files
 
 +filename(file) -> string+::   Obtain the name of a file
@@ -469,71 +423,6 @@
 The builtin functions mentioned above are implemented as extension
 functions in Tcl.
 
-=== Swift extension functions
-
-Currently we support Tcl extension functions, where a function is implemented
-as a Tcl function.  Tcl has good support for wrapping native C/C\++ functions,
-so this provides an indirect way to call C/C++ functions from Swift.
-
-Several components are required to implement a Tcl extension:
-
--  Tcl bindings to your function.
--  For complex types such as structures, arrays and files, you may need
-   additional logic to marshal inputs and outputs to/from the global
-   data store.
--  The requisite files required to build a Tcl package (e.g pkgIndex.tcl)
--  Swift declarations for the function that specify the type of the function
-    and the Tcl implementation.
-
-==== Simple Tcl Function Example
-In this first example we will implement a trivial Tcl extension function
-that doubles an integer.  Here is the Tcl code that will go in
-+myextension.tcl+:
-
-----
-namespace eval myextension {
-  proc double { x } {
-    return [ expr $x * 2 ]
-  }
-}
-----
-
-* TODO: info on how to create Tcl package, e.g. pkgIndex.tcl
-
-Here is the Swift function definition that will go in +myextension.swift+:
-----
- at pure
-(int o) double (int i) "myextension" "0.0.1" [
-  "set <<o>> [ myextension::double <<i>> ]"
-];
-----
-
-The above definition has, from left to right, the output arguments,
-the name of the new Swift function, input arguments, the name
-of the Tcl package containing the file, and the minimum version
-of that package.
-
-We tell the compiler how to call our Tcl function using inline
-Tcl code as a template with variable names surrounded by +<< >>+
-indicating where variables should be substituted.
-
-We can also tell the Swift compiler a little about the function so
-that it can better optimize your programs.
-For example, +double+ has no side-effects and produces the same result each
-time for the same arguments (i.e. is deterministic), so we can flag
-it as a + at pure+ function.
-
-If your function has a long running time and should be dispatched
-to a worker process for execution, then you need to label the
-function as a leaf function, for example:
-
-----
- at dispatch=LEAF
-(int o) process (int i) "pkg" "0.0.1" [
-  "set <<o>> [ pkg::process <<i>> ]"
-];
-----
-
 === App functions
 
 App functions are functions that are implemented as command-line

Modified: trunk/docs/userguide/mappers
===================================================================
--- trunk/docs/userguide/mappers	2013-03-12 19:20:37 UTC (rev 6374)
+++ trunk/docs/userguide/mappers	2013-03-12 20:32:37 UTC (rev 6375)
@@ -244,7 +244,24 @@
 subsequent case blocks, and no break statement is necessary at the
 end of each block.
 
+Following is an example of a switch expression in Swift:
 
+----
+int score=60;
+switch (score){
+case 100:
+    tracef("%s\n", "Bravo!");
+case 90:
+    tracef("%s\n", "very good");
+case 80:
+    tracef("%s\n", "good");
+case 70:
+    tracef("%s\n", "fair");
+default:
+    tracef("%s\n", "unknown grade");
+    }
+----
+
 iterate
 ^^^^^^^
 iterate expressions allow a block of code to be evaluated repeatedly,




More information about the Swift-commit mailing list