[Swift-commit] r8394 - www/Swift-T

wozniak at ci.uchicago.edu wozniak at ci.uchicago.edu
Mon Mar 16 11:51:37 CDT 2015


Author: wozniak
Date: 2015-03-16 11:51:36 -0500 (Mon, 16 Mar 2015)
New Revision: 8394

Modified:
   www/Swift-T/gallery.html
   www/Swift-T/guide.html
Log:
Gallery updates


Modified: www/Swift-T/gallery.html
===================================================================
--- www/Swift-T/gallery.html	2015-03-13 20:03:05 UTC (rev 8393)
+++ www/Swift-T/gallery.html	2015-03-16 16:51:36 UTC (rev 8394)
@@ -791,6 +791,58 @@
 <div class="sect1">
 <h2 id="_swift_t_for_shell_users">2. Swift/T for shell users</h2>
 <div class="sectionbody">
+<div class="paragraph"><p>Swift/T has a powerful shell interface in its
+<a href="guide.html#app_functions">app function</a> syntax.  Here are some
+advanced examples:</p></div>
+<div class="paragraph"><p>To pass a whole command line into a generic app function, use:</p></div>
+<div class="paragraph"><p><strong>File:</strong> <code>sh-c/sh-1.swift</code></p></div>
+<div class="listingblock">
+<div class="content">
+<pre><code>import string;
+app f(string commandline)
+{
+  "sh" "-c" commandline;
+}
+tokens = ["/bin/echo","this","is","my","message"];
+f(string_join(tokens," "));</code></pre>
+</div></div>
+<div class="paragraph"><p>producing:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><code>this is my message</code></pre>
+</div></div>
+<div class="paragraph"><p>Programs that are found in different locations on different machines
+can be accessed like this:</p></div>
+<div class="paragraph"><p><strong>File:</strong> <code>sh-c/sh-2.swift</code></p></div>
+<div class="listingblock">
+<div class="content">
+<pre><code>import string;
+import sys;
+
+// Program configuration
+string program;
+if (getenv("HOST") == "umbra")
+{
+  program = "/bin/echo";
+}
+else
+{
+  // something else
+}
+// End program configuration
+
+app f(string arguments)
+{
+  program arguments;
+}
+tokens = ["this","is","my","message"];
+f(string_join(tokens," "));</code></pre>
+</div></div>
+<div class="paragraph"><p>You can put the "program configuration" section in a separate file and
+<a href="guide.html#modules"><code>import</code></a> it.</p></div>
+<div class="paragraph"><p>If you prefer, you could also put separate definitions of <code>program</code> in
+separate files and <a href="guide.html#cpp_macro">conditionally <code>#include</code></a>
+them with STC support for the <a href="guide.html#cpp">C preprocessor</a>.</p></div>
 <div class="paragraph"><p>This script converts itself to octal in <code>mtc.octal</code>.</p></div>
 <div class="paragraph"><p><strong>File:</strong> <code>mtc/mtc1.swift</code></p></div>
 <div class="listingblock">
@@ -852,7 +904,7 @@
 <div class="paragraph"><p>A shorter, equivalent form of that command sequence is:</p></div>
 <div class="listingblock">
 <div class="content">
-<pre><code>swift-t -t:f hosts.txt -n 4 mtc1.swift</code></pre>
+<pre><code>swift-t -t f:hosts.txt -n 4 mtc1.swift</code></pre>
 </div></div>
 <div class="paragraph"><p>On a PBS system, run with:</p></div>
 <div class="listingblock">
@@ -881,7 +933,7 @@
   "/bin/echo" s @stdout=o;
 }
 
-string lines[] = file_lines(input("mtc2.swift"));
+string lines[] = file_lines(input("mtc3.swift"));
 file fragments[];
 foreach line,i in lines
 {
@@ -1085,7 +1137,7 @@
 <div id="footnotes"><hr /></div>
 <div id="footer">
 <div id="footer-text">
-Last updated 2015-03-05 13:57:37 CST
+Last updated 2015-03-16 11:46:04 CDT
 </div>
 </div>
 </body>

Modified: www/Swift-T/guide.html
===================================================================
--- www/Swift-T/guide.html	2015-03-13 20:03:05 UTC (rev 8393)
+++ www/Swift-T/guide.html	2015-03-16 16:51:36 UTC (rev 8394)
@@ -744,7 +744,7 @@
 <body class="article" style="max-width:750px">
 <div id="header">
 <h1>Swift/T Guide</h1>
-<span id="author">v0.7.0, November 2014</span><br />
+<span id="author">v0.8.0, March 2015</span><br />
 <div id="toc">
   <div id="toctitle">Table of Contents</div>
   <noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
@@ -988,6 +988,7 @@
 compile-time. This may be found at runtime using the Swift
 <a href="#argv">argument processing</a> library. This option enables these
 arguments to be treated as compile-time constants for optimization.
+<a id="cpp_macro"></a>  
 </p>
 </dd>
 <dt class="hdlist1">
@@ -1067,7 +1068,7 @@
 <div class="paragraph"><p>STC runs as a Java program.  You may use <code>-j</code> to set the Java VM
 executable.  This Java VM must be compatible with the <code>javac</code> used to
 compile STC.</p></div>
-<div class="paragraph"><p>By default, STC runs the user script through the C preprocessor
+<div class="paragraph" id="cpp"><p>By default, STC runs the user script through the C preprocessor
 (<code>cpp</code>), enabling arbitrary macro processing, etc.  The <code>-D</code>, <code>-E</code>,
 <code>-I</code>, and <code>-p</code> options are relevant to this feature.</p></div>
 <div class="paragraph"><p>Additional arguments for advanced users/developers:</p></div>
@@ -1164,7 +1165,7 @@
 </div>
 </div>
 <div class="sect1">
-<h2 id="_modules">6. Modules</h2>
+<h2 id="modules">6. Modules</h2>
 <div class="sectionbody">
 <div class="paragraph"><p>Swift has a module system that allows you to import function and variable
 definitions into your source file.  Importing a module will import all
@@ -3899,7 +3900,7 @@
 <p>
 Disable logging. <code>TURBINE_LOG=1</code> or unset enables
 logging, assuming logging was not disabled at configure time.  Logging
-goes to tandard output by default.
+goes to standard output by default.
 </p>
 </dd>
 <dt class="hdlist1">
@@ -4493,7 +4494,7 @@
 <div id="footnotes"><hr /></div>
 <div id="footer">
 <div id="footer-text">
-Last updated 2015-03-05 12:25:57 CST
+Last updated 2015-03-16 11:43:18 CDT
 </div>
 </div>
 </body>




More information about the Swift-commit mailing list