9 \subtitle{\texttt{<splc>~::= <spl> <parser> `,' <lexer> `and' <compiler>
}}
10 \author[P. Jager, M. Lubbers
]{Pim Jager
\inst{1}\and Mart Lubbers
\inst{1}}
11 \institute[Radboud University
]{%
13 Computer Science: Software Science\\
16 \subject{SPL Compiler
}
20 basicstyle=
\ttfamily\footnotesize,
25 \usecolortheme{beaver
}
30 \begin{frame
}[fragile
]
33 \item Higher order functions
34 \item Anonymous lambda functions
41 \begin{frame
}[fragile
]
42 \frametitle{Higher order functions implemented using function pointers
}
45 map(f, xs) :: (a -> b) ->
[a
] ->
[b
] {
46 if( isEmpty(xs) )
{ return
[];
}
47 else
{ return f(xs.hd) : map(f, xs.tl);
}
57 \item Function arguments are passed by name.
58 \item During compilation these are replaced by unique function ID's
59 \item During runtime the corresponding function label is retrieved using
60 a dictionary like approach.
65 \begin{frame
}[fragile
]
66 \frametitle{Function application can be curried
}
69 plus(x,y) :: Int -> Int -> Int
{
74 map(plus(
4),
1:
2:
3:
[]);
79 \begin{column
}[T
]{0.5\textwidth}
81 \item Function ID is placed on the heap
82 \item Number of passed arguments is placed on the heap
83 \item Arguments are pushed on the heap
87 \begin{column
}[T
]{0.5\textwidth}
88 \begin{block
}{Heap contents
}
89 \begin{tabular
}{c | l | r
}
90 address & Content & \\
\hline
102 \begin{frame
}[fragile
]
103 \frametitle{SPLC has lambda functions through AST rewriting
}
104 \framesubtitle{\texttt{<LamdaExpr> ::= `
\textbackslash'<id>*
106 \begin{block
}{Implementation
}<
3->
107 Implemented by promoting lambdas to regular named functions
108 prior to semantical analysis.
111 \begin{column
}[T
]{0.5\textwidth}<
1->
114 map(
\x-> x+
1,
1:
2:
3:
[]);
118 \begin{column
}[T
]{0.5\textwidth}<
4->
124 map(
1lambda_
23,
1:
2:
3:
[]);
130 \item<
2-> SPLC supports anonymous lambda functions with arbitrary arity
131 \item<
2-> Lambdas are fully type checked, same as regular functions
135 \begin{frame
}[fragile
]
136 \frametitle{Syntactic sugar to ease our programmers lives
}
137 \begin{block
}{Global constants
}
139 \item SPLC does
\emph{not
} feature global variables.
141 \item We want to protect our users from global state (as much
144 \item Global constants allowed through
\texttt{let
} statements
145 \item \texttt{<LetDecl> ::= `let' <type> <id> `=' <Expr> `;'
}
146 \item Lets are rewritten to constant functions
149 \begin{column
}[T
]{0.4\linewidth}
154 \begin{column
}[T
]{0.4\linewidth}
156 x() :: Int
{ return
5;
}
163 \begin{frame
}[fragile
]
164 \frametitle{Syntactic sugar to ease our programmers lives
}
165 \framesubtitle{continued
}
166 \begin{block
}{String Literals
}
168 \begin{column
}[T
]{0.34\linewidth}
170 var a = "Hello world!";
173 \begin{column
}[T
]{0.5\linewidth}
175 var a = 'H':'e':'l':'l':'o':' ':
176 'w':'o':'r':'l':'d':'!':
[];
181 \begin{block
}{List Literals
}
183 \begin{column
}[T
]{0.34\linewidth}
188 \begin{column
}[T
]{0.5\linewidth}
195 \begin{block
}{Variable argument printing
}
197 \begin{column
}[T
]{0.34\linewidth}
199 print("x is: ", x, "
\n");
202 \begin{column
}[T
]{0.5\linewidth}
213 \begin{frame
}[fragile
]
214 \frametitle{Improvements and Future Work
}
215 \begin{block
}{Improve type checker
}
216 Type checker allows some programs which should not be allowed\\
217 e.g. the polymorphic value examples of Markus.
220 \begin{block
}{Improve overloaded equality
}
221 Equality only preforms shallow (JAVA-style) equality on Lists and Tuple
225 \begin{block
}{Improve error reporting
}
226 Not all errors are reported with the position the error occurs in. Most
227 notably type errors always occur on position (
0,
0).
232 \frametitle{Questions \& Cool demo's
}