
diff -r 183663740fb7 -r 6f3f3dd01786 handouts/ho08.tex
--- a/handouts/ho08.tex	Mon Feb 03 01:10:16 2020 +0000
+++ b/handouts/ho08.tex	Tue Feb 04 09:31:18 2020 +0000
@@ -58,7 +58,7 @@
 \end{lstlisting}
 
 \noindent Compare the code of the fib-program with the same program
-written in the While-language\ldots Fun is definitely more comfortable.
+written in the WHILE-language\ldots Fun is definitely more comfortable.
 We will still focus on programs involving integers only, that means for
 example that every function in Fun is expected to return an integer. The
 point of the Fun language is to compile each function to a separate
@@ -66,7 +66,7 @@
 we need to adapt to some of the conventions of the JVM about methods.
 
 The grammar of the Fun-language is slightly simpler than the
-While-language, because the main syntactic category are
+WHILE-language, because the main syntactic category are
 expressions (we do not have statements in Fun). The grammar rules are
 as follows:\footnote{We of course have a slightly different (non-left-recursive)
 grammar for our parsing combinators. But for simplicity sake we leave
@@ -135,16 +135,17 @@
 case class Main(e: Exp) extends Decl
 \end{lstlisting}}
 
-Let us first look at some clauses for compiling expressions. The
-compilation of arithmetic and boolean expressions is just like for the
-While-language and does not need any modification (recall that the
+The rest of the hand out is about compiling this language. Let us first
+look at some clauses for compiling expressions. The compilation of
+arithmetic and boolean expressions is just like for the WHILE-language
+and does not need any modification (recall that the
 \textit{compile}-function for boolean expressions takes a third argument
 for the label where the control-flow should jump when the boolean
 expression is \emph{not} true---this is needed for compiling
 \pcode{if}s). One additional feature in the Fun-language are sequences.
 Their purpose is to do one calculation after another or printing out an
 intermediate result. The reason why we need to be careful however is the
-convention that every expression can only produce s single result
+convention that every expression can only produce a single result
 (including sequences). Since this result will be on the top of the
 stack, we need to generate a \pcode{pop}-instruction for sequences in
 order to clean-up the stack. For example, for an expression of the form
@@ -195,7 +196,7 @@
 \end{lstlisting}
 
 \noindent We also need to first generate code for the
-argument-expression of write, which in the While-language was
+argument-expression of write, which in the WHILE-language was
 only allowed to be a single variable.
 
 Most of the new code in the compiler for the Fun-language
@@ -347,9 +348,10 @@
  
 \subsection*{Tail-Call Optimisations}
 
-Let us now briefly touch upon the vast topic of compiler optimisations.
-As an example, let's perform tail-call optimisations for our
-Fun-language. Consider the following version of the factorial function:
+Let us now briefly touch again upon the vast topic of compiler
+optimisations. As an example, let's perform tail-call optimisations for
+our Fun-language. Consider the following version of the factorial
+function:
 
 \begin{lstlisting}
 def facT(n, acc) = 
@@ -358,7 +360,7 @@
 \end{lstlisting}
 
 \noindent 
-The corrsponding JVM code for this function is below:
+The corresponding JVM code for this function is below:
 
 \begin{lstlisting}[language=JVMIS, numbers=left]
 .method public static facT(II)I 
@@ -392,13 +394,14 @@
 recursively. Each call results in some hefty overhead on the
 stack---ultimately leading to a stack overflow. Well, it is possible to
 avoid this overhead completely in many circumstances. This is what
-tail-call optimisations are about.   
+\emph{tail-call optimisations} are about.   
 
 Note that the call to \code{facT} in the program is the last instruction
 before the \code{ireturn} (the label in Line 17 does not count since it
 is not an instruction). Also remember, before we make the recursive call
-the arguments of \code{facT} need to put on the stack. Once we are
-``inside'' the arguments on the stack turn into local variables. Therefore 
+the arguments of \code{facT} need to be put on the stack. Once we are
+``inside'' the function, the arguments on the stack turn into local
+variables. Therefore 
 \code{n} and \code{acc} are referenced inside the function with \pcode{iload 0}
 and \pcode{iload 1} respectively.
 




