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{How to put labels on the heap
}
68 \item Function ID in register
69 \item \texttt{bsr
} to
\texttt{1func
}
70 \item \texttt{1func
} \texttt{bra
} to correct function
71 \item Actual function returns in usual way
75 \begin{frame
}[fragile
]
76 \frametitle{Function application can be curried
}
79 plus(x,y) :: Int -> Int -> Int
{
84 map(plus(
4),
1:
2:
3:
[]);
89 \begin{column
}[T
]{0.5\textwidth}
91 \item Function ID is placed on the heap
92 \item Number of passed arguments is placed on the heap
93 \item Arguments are pushed on the heap
97 \begin{column
}[T
]{0.5\textwidth}
98 \begin{block
}{Heap contents
}
99 \begin{tabular
}{c | l | r
}
100 address & Content & \\
\hline
112 \begin{frame
}[fragile
]
113 \frametitle{SPLC has lambda functions through AST rewriting
}
114 \framesubtitle{\texttt{<LamdaExpr> ::= `
\textbackslash'<id>*
116 \begin{block
}{Implementation
}<
3->
117 Implemented by promoting lambdas to regular named functions
118 prior to semantical analysis.
121 \begin{column
}[T
]{0.5\textwidth}<
1->
124 map(
\x-> x+
1,
1:
2:
3:
[]);
128 \begin{column
}[T
]{0.5\textwidth}<
4->
134 map(
1lambda_
23,
1:
2:
3:
[]);
140 \item<
2-> SPLC supports anonymous lambda functions with arbitrary arity
141 \item<
2-> Lambdas are fully type checked, same as regular functions
145 \begin{frame
}[fragile
]
146 \frametitle{Syntactic sugar to ease our programmers lives
}
147 \begin{block
}{Global constants
}
149 \item SPLC does
\emph{not
} feature global variables.
151 \item We want to protect our users from global state (as much
154 \item Global constants allowed through
\texttt{let
} statements
155 \item \texttt{<LetDecl> ::= `let' <type> <id> `=' <Expr> `;'
}
156 \item Lets are rewritten to constant functions
159 \begin{column
}[T
]{0.4\linewidth}
164 \begin{column
}[T
]{0.4\linewidth}
166 x() :: Int
{ return
5;
}
173 \begin{frame
}[fragile
]
174 \frametitle{Syntactic sugar to ease our programmers lives
}
175 \framesubtitle{continued
}
176 \begin{block
}{String Literals
}
178 \begin{column
}[T
]{0.34\linewidth}
180 var a = "Hello world!";
183 \begin{column
}[T
]{0.5\linewidth}
185 var a = 'H':'e':'l':'l':'o':' ':
186 'w':'o':'r':'l':'d':'!':
[];
191 \begin{block
}{List Literals
}
193 \begin{column
}[T
]{0.34\linewidth}
198 \begin{column
}[T
]{0.5\linewidth}
205 \begin{block
}{Variable argument printing
}
207 \begin{column
}[T
]{0.34\linewidth}
209 print("x is: ", x, "
\n");
212 \begin{column
}[T
]{0.5\linewidth}
223 \begin{frame
}[fragile
]
224 \frametitle{Improvements and Future Work
}
225 \begin{block
}{Improve type checker
}
226 Type checker allows some programs which should not be allowed\\
227 e.g. the polymorphic value examples of Markus.
230 \begin{block
}{Improve overloaded equality
}
231 Equality only preforms shallow (JAVA-style) equality on Lists and Tuple
235 \begin{block
}{Improve error reporting
}
236 Not all errors are reported with the position the error occurs in. Most
237 notably type errors always occur on position (
0,
0).
242 \frametitle{Questions \& Cool demo's
}