[Swift-commit] r3332 - text/internals/trunk
noreply at svn.ci.uchicago.edu
noreply at svn.ci.uchicago.edu
Thu May 13 14:51:28 CDT 2010
Author: aespinosa
Date: 2010-05-13 14:51:27 -0500 (Thu, 13 May 2010)
New Revision: 3332
Modified:
text/internals/trunk/internals.tex
Log:
Raw notes last last week
Modified: text/internals/trunk/internals.tex
===================================================================
--- text/internals/trunk/internals.tex 2010-05-05 16:06:08 UTC (rev 3331)
+++ text/internals/trunk/internals.tex 2010-05-13 19:51:27 UTC (rev 3332)
@@ -182,5 +182,183 @@
)
\end{verbatim}
+\subsection{Elements}
+Example: recursive list
+
+\begin{verbatim}
+element(f, [n]
+ if(n == 0, 0,
+ n,
+ f(n-1) )
+)
+l := list(f(10))
+\end{verbatim}
+
+equivalent to
+\begin{verbatim}
+l := list(10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
+\end{verbatim}
+
+Expansion :
+
+f(10) -> 10, f(9) -> 10, 9, f(8) -> ...
+
+At some point there will be 10 stackframes active.
+
+Positional arguments are always required, Optional arguments cannot be specified
+positionally.
+
+\section{Unreturned arguments}
+... = vargs. should always be last in an element definition. Stuck in the
+default channel
+
+element(f, [...]
+ each(...)
+)
+
+f(1,2,3) -> 1,2,3
+
+element(f, [...]
+ for(i, ...
+ i
+ )
+)
+
+Optional arguments cannot be expressed in positional form
+
+\section{Named channels}
+
+Multiple varargs
+
+channel(a) - an implicit channel
+
+to(a, 1,2,3)
+
+example
+
+element(fc, [b, channel(a)]
+ for(i, a,
+ echo(b, '-', i)
+ )
+)
+
+Used in generating a graphviz DAG
+
+parallelElement(con, [channel(c)]
+ for(i, c
+ echo(i)
+ )
+)
+
+element(gen, []
+ for(i, range(0,10),
+ wait(delay=1000), i
+ )
+)
+
+con(gen())
+
+Print as a channel:
+print("a") -> to(stdout, "a")
+
+You can intercept a channel. Other purely functional languages like Haskell
+messes up this side effect.
+
+element(x, [channel(stdout)]
+ a := first(stdout)
+ echo(reverse(a))
+)
+
+x(print("abc"))
+
+dumps "cba"
+
+\sectio{Swift compilation}
+
+swift source -> parser -> vdlx -> dump parser / compiled /translated -> .kml
+
+down tree. static type checking, limited data flow analysis
+
+.kml uses some libraries vdl-int.k, vdl.k, vdl-sc.k, vdl-lib.xml - java defined
+elements
+
+vdl-sc.k -> site catalog parsing
+
+execute-*.k
+
+vdl.k, vdl-lib.k -> publicly accessible by the kml file. encapsulation issues
+
+vdl-lib.xml -> mapping functions (extractint, etc, @java),
+ -> data manipulation
+ -> two namespaces vdl and swiftscript
+
+"swiftscript" : actual mapping functions @name
+ @name = filename(foo) equivalent to C's '&'
+
+originally @no data flow with mapping functions. limited processing on a string
+. supposed to assist in the mapping functions
+
+vdl : - dataset functions
+ - directory manipulation (basename, dirname). used internally
+
+cdm: - cdm functions
+
+\section{first.swift}
+
+In normal karajan (not compiled xml)
+
+element(greeting, [t]
+ vdl:execute(
+ vdl:tr("echo")
+ vdl:stageout(t)
+ vdl:arguments("Hello world")
+ vdl:stdout(swifscript:filename(t))
+ )
+ vdl:closedataset(t)
+)
+
+With input parameter
+
+type file;
+app (file m) greeting(string msg) {
+ echo msg stdout=@filename(t);
+}
+
+file outf<"a.txt">;
+outf = greeting("Hello world");
+
+compiled
+
+element(greeting, [t, msg]
+ vdl:execute(
+ vdl:tr("echo")
+ vdl:stageout(t)
+ vdl:arguments(vdl:getfieldvalue(msg))
+ vdl:stdout(swifscript:filename(t))
+ )
+ vdl:closedataset(t)
+)
+
+\section{DSHandle}
+
+Most primitive representation of a swift piece of data. A pointer. The hash
+table is filled with DSHandle values. Pointer descriptor of a swift object
+
+A tree
+
+Scalar = just a struct
+
+Implements -> scalar, array, structs, etc.
+
+More or relation to nodes than the names of the nodes in itself
+
+All data variables in swift (dshandles) are futures.
+
+
+string s = "x"; ->
+
+s=vdl:new(...)
+vdl:setfieldvalue(s, "x")
+
\end{document}
More information about the Swift-commit
mailing list