From: pimjager Date: Mon, 30 May 2016 16:08:31 +0000 (+0200) Subject: First version slides X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=c846908e1897ddeed7db6628abd2445edd3aedf3;p=cc1516.git First version slides --- diff --git a/deliverables/p4/p4.tex b/deliverables/p4/p4.tex index adc62d2..36fdaf1 100644 --- a/deliverables/p4/p4.tex +++ b/deliverables/p4/p4.tex @@ -87,4 +87,117 @@ main() { \end{frame} + +\begin{frame}[fragile] + \frametitle{SPLC has lambda functions through AST rewriting} + \framesubtitle{\texttt{ ::= `\textbackslash'* + `->' }} + \begin{block}{Implementation}<3-> + Implemented by promoting lambdas to regular named functions + prior to semantical analysis. + \end{block} + \begin{columns} + \begin{column}[T]{0.5\textwidth}<1-> + \begin{SPLCode} +main() { + map(\x-> x+1, 1:2:3:[]); +} + \end{SPLCode} + \end{column} + \begin{column}[T]{0.5\textwidth}<4-> + \begin{SPLCode} +1lambda_23(x) { + return x+1; +} +main() { + map(1lambda_23, 1:2:3:[]); +} + \end{SPLCode} + \end{column} + \end{columns} + \begin{itemize} + \item<2-> SPLC supports anonymous lambda functions with arbitrary arity + \item<2-> Lambdas are fully type checked, same as regular functions + \end{itemize} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Syntactic sugar to ease our programmers lives} + \begin{block}{Global constants} + \begin{itemize} + \item SPLC does \emph{not} feature global variables. + \begin{itemize} + \item We want to protect our users from global state (as much + as possible). + \end{itemize} + \item Global constants allowed through \texttt{Let} statements + \item \texttt{ ::= `Let' `=' `;'} + \item Lets are rewritten to constant functions + \end{itemize} + \begin{columns}[T] + \begin{column}[T]{0.4\linewidth} + \begin{SPLCode} +Let Int x = 5; + \end{SPLCode} + \end{column} + \begin{column}[T]{0.4\linewidth} + \begin{SPLCode} +x() :: Int { return 5; } + \end{SPLCode} + \end{column} + \end{columns} + \end{block} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Syntactic sugar to ease our programmers lives} + \framesubtitle{continued} + \begin{block}{String Literals} + \begin{columns}[T] + \begin{column}[T]{0.34\linewidth} + \begin{SPLCode} +var a = "Hello world!"; + \end{SPLCode} + \end{column} + \begin{column}[T]{0.5\linewidth} + \begin{SPLCode} +var a = 'H':'e':'l':'l':'o':' ': + 'w':'o':'r':'l':'d':'!':[]; + \end{SPLCode} + \end{column} + \end{columns} + \end{block} + \begin{block}{List Literals} + \begin{columns}[T] + \begin{column}[T]{0.34\linewidth} + \begin{SPLCode} +var xs = [1,2,3]; + \end{SPLCode} + \end{column} + \begin{column}[T]{0.5\linewidth} + \begin{SPLCode} +var xs = 1:2:3:[]; + \end{SPLCode} + \end{column} + \end{columns} + \end{block} + \begin{block}{Variable argument printing} + \begin{columns}[T] + \begin{column}[T]{0.34\linewidth} + \begin{SPLCode} +print("x is: ", x); + \end{SPLCode} + \end{column} + \begin{column}[T]{0.5\linewidth} + \begin{SPLCode} +print("x is: "); +print(x); + \end{SPLCode} + \end{column} + \end{columns} + \end{block} +\end{frame} + + + \end{document}