
diff -r 2ab96407f350 -r d3d371ae5fab handouts/ho09.tex
--- a/handouts/ho09.tex	Sat Sep 09 14:14:31 2023 +0100
+++ b/handouts/ho09.tex	Sun Sep 10 12:24:55 2023 +0100
@@ -785,6 +785,44 @@
 \end{figure}
 
 
+\section*{Alternatives to CPS}
+
+While I appreciate that this handout is already pretty long, this
+section is for students who think the CPS-translation is too much of
+voodoo programming---there is a perhaps simpler alternative. This
+alternative is along the lines: if you cannot bridge the gap in
+a single step, do it in two simpler steps. Let's look at the
+simple expression $1 + (2 + 3)$. The CPS-translation correctly
+generates the expression
+
+\begin{lstlisting}[language=LLVMIR,numbers=left,escapeinside={(*@}{@*)}]
+let tmp0 = add 2 3 in   
+let tmp1 = add 1 tmp0 in 
+  return tmp1 
+\end{lstlisting}
+
+\noindent
+where $(2 + 3)$ is pulled out and calculated first. The problem is that it
+requires a bit of magic. But with the ability to give a separate variable
+to each indivifual computation, we could do the following: The expression
+$1 + (2 + 3)$ is a tree like this
+
+\begin{center}
+\begin{tikzpicture}[line width=1mm]
+  \node {root} [grow'=up]
+    child {node {1}}
+    child {node[circle,draw] {+}
+      child {node {2}}
+      child {node {3}}
+    };
+\end{tikzpicture}
+\end{center}
+
+\noindent
+and we could perform a completely standard recursive traversal of the
+tree: each inner node gets a new variable and assignment.  
+
+
 
 \noindent
 \end{document}




