handouts/ho09.tex
changeset 360 eb2004430215
parent 359 c90f803dc7ea
child 366 34a8f73b2c94
--- a/handouts/ho09.tex	Sat Dec 20 14:48:15 2014 +0000
+++ b/handouts/ho09.tex	Sat Dec 27 04:10:36 2014 +0000
@@ -194,11 +194,11 @@
 Designing a language is like playing god: you can say what
 names for variables you allow; what programs should look like;
 most importantly you can decide what each part of the program
-should mean and do. While our language is rather simple and
-the meaning of statements, for example, is rather
-straightforward, there are still places where we need to make
-real choices. For example consider the conditional jumps, say
-the one in the factorial program: 
+should mean and do. While our language is quite simple and the
+meaning of statements, for example, is rather straightforward,
+there are still places where we need to make real choices. For
+example consider the conditional jumps, say the one in the
+factorial program: 
 
 \begin{center}
 \code{jmp? n = 0 done}
@@ -224,12 +224,10 @@
 
 First we will pre-process our programs. This will simplify the
 definition of our interpreter later on. By pre-processing our
-programs we will transform programs into \emph{snippets}.
-Their purpose is to simplify the definition of what the
-interpreter should do in case of a jump. A snippet is a label
-and all the code that comes after the label. This essentially
-means a snippet is a \emph{map} from labels to
-code.\footnote{Be sure you know what maps are. In a
+programs we will transform programs into \emph{snippets}. A
+snippet is a label and all the code that comes after the
+label. This essentially means a snippet is a \emph{map} from
+labels to code.\footnote{Be sure you know what maps are. In a
 programming context they are often represented as association
 list where some data is associated with a key.} 
 
@@ -527,16 +525,70 @@
 $\textit{eval\_stmts}(sn(\pcode{""}), \varnothing)$
 \end{center}
  
-\noindent It is interesting to not that our interpreter when
+\noindent It is interesting to note that our interpreter when
 it comes to the end of the program returns an environment. Our
 programming language does not contain any constructs for input
 and output. Therefore this environment is the only effect we
 can observe when running the program (apart from that our
 interpreter might need some time before finishing the
-evaluation of the program)
+evaluation of the program and the CPU getting hot). Evaluating 
+the factorial program with our interpreter we receive as
+``answer''-environment
+
+\begin{center}
+\begin{tabular}{ll}
+$\fbox{\texttt{a}} \mapsto \texttt{120}$ &
+$\fbox{\texttt{n}} \mapsto \texttt{0}$
+\end{tabular}
+\end{center}
+
+\noindent While the discussion above should have illustrated
+the ideas, in order to do some serious calculation we clearly
+need to implement the interpreter.
 
 
+\subsubsection*{Code of the Interpreter}
 
+Functional programming languages are very convenient for
+implementations of interpreters. A convenient choice for a
+functional programming language is Scala. This is a
+programming language that combines functional and
+object-oriented programming-styles. It has received in the
+last five years or so quite a bit of attention. One reason for
+this attention is that, like the Java programming language,
+Scala compiles to the Java Virtual Machine (JVM) and therefore
+Scala programs can run under MacOSX, Linux and
+Windows.\footnote{There are also experimental backends for
+Android and JavaScript.} Unlike Java, however, Scala often
+allows programmers to write very concise and elegant code.
+Some therefore say Scala is the much better Java. A number of
+companies, The Guardian, Twitter, Coursera, FourSquare,
+LinkedIn to name a few, either use Scala exclusively in
+production code, or at least to some substantial degree. If
+you want to try out Scala yourself, the Scala compiler can be
+downloaded from
+
+\begin{quote}
+\url{http://www.scala-lang.org}
+\end{quote}
+
+
+\begin{figure}[t]
+\small
+\lstinputlisting[language=Scala]{../progs/inter.scala}
+\caption{Bla}
+\end{figure}
+
+
+\subsubsection*{Static Analysis}
+
+Finally we can come back to our original problem, namely 
+finding out what the signs of variables are 
+
+\begin{center}
+
+
+\end{center}
  
 \end{document}