Commit e6511be5 by Mark Cohen

presentation: more progress

parent 1f13b090
Showing with 33 additions and 11 deletions
......@@ -206,17 +206,18 @@ end
Traits are subordinate to \emph{object-oriented} classes.
}
\note[item]{
The authors of the seminal paper on traits present them as subordinate to object-oriented
classes; traits can't imply each other, which we'll discuss more later on.
Sch{\"a}rli et al. present as subordinate to object oriented classes
}
\note[item]{
Different problem domain; can't have traits imply other traits
}
\item<3->{
The "type ownership" problem is baked in to the existing theory.
}
\note[item]{
Given the motivation of traits as subordinate to object-oriened classes, it makes sense that
you must own a type to implement a trait, since you'll almost always own all of a class
hierarchy.
Since traits were developed alongside object-oriented classes, there was no need to allow
instances for types not owned by the programmer
}
\end{itemize}
......@@ -499,8 +500,8 @@ instance Collectible $\alpha$ list where
\begin{onlyenv}<4->
\vspace{-16pt}
\begin{lstlisting}[mathescape=true]
for x in [1, 2, 3, 4]: int list
collect (fn x => x + 1)
for x in [1, 2, 3, 4] $\arrow$ int list
collect (x + 1)
\end{lstlisting}
\end{onlyenv}
\note[item]{
......@@ -518,7 +519,7 @@ instance Collectible string where
val default = ""
val insert = concat
for x in ["hi", " ", "world", "!"]: string
for x in ["hi", " ", "world", "!"] $\arrow$ string
collect x
\end{lstlisting}
\note[item]{
......@@ -534,7 +535,7 @@ for x in ["hi", " ", "world", "!"]: string
\begin{frame}[fragile]{Desired design}
How about \tt{filter}?
\begin{lstlisting}[mathescape=true]
for id in users: string list
for id in users $\arrow$ string list
if registered? id
then collect id
else pass
......@@ -1038,7 +1039,7 @@ instance Iterable string where
Recall our desired designs:
\begin{lstlisting}[mathescape=true]
for x in [1, 2, 3, 4] $\arrow$ int list
collect (fn x => x + 1)
collect (x + 1)
for x in ["hi", " ", "world", "!"] $\arrow$ string
collect x
......@@ -1062,7 +1063,7 @@ for id in users $\arrow$ string list
\begin{frame}[fragile]{Iteration: \texttt{\Large for} formalism}
\begin{lstlisting}[mathescape=true]
for <var> in <collection>: <ty>
for <var> in <collection> $\arrow$ <ty>
<expr>
\end{lstlisting}
......@@ -1159,6 +1160,27 @@ pass
\end{frame}
\begin{frame}[fragile]{Iteration: big payoff!}
\begin{lstlisting}[mathescape=true]
val pass = fn _ => None
val collect = fn x => Some x
val for = fn var collection $\iota$ expr =>
case (next collection)
of None => $\iota$
| Some (item, rest) =>
case (expr item)
of Some item' => for var rest (insert $\iota$ item') expr
| None => for var rest $\iota$ expr
\end{lstlisting}
\begin{onlyenv}<2->
\begin{lstlisting}[mathescape=true]
<expr> $\mapsto$ fn <var> => <expr>
\end{lstlisting}
\end{onlyenv}
\end{frame}
\begin{frame}{}
\begin{center}
\Large Thank you!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment