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
]
31 \frametitle{Higher order functions implemented using function pointers
}
34 map(f, xs) :: (a -> b) ->
[a
] ->
[b
] {
35 if( isEmpty(xs) )
{ return
[];
}
36 else
{ return f(xs.hd) : map(f, xs.tl);
}
46 \item Function arguments are passed by name.
47 \item During compilation these are replaced by unique function ID's
48 \item During runtime the corresponding function label is retrieved using
49 a dictionary like approach.
54 \begin{frame
}[fragile
]
55 \frametitle{Functions application can be curried
}
58 plus(x,y) :: Int -> Int -> Int
{
63 map(plus(
1),
1:
2:
3:
[]);
68 \begin{column
}[T
]{0.5\textwidth}
70 \item Function ID is placed on the heap
71 \item Number of passed arguments is placed on the heap
72 \item Arguments are pushed on the heap
76 \begin{column
}[T
]{0.5\textwidth}
77 \begin{block
}{Heap contents
}
78 \begin{tabular
}{c | l | r
}
79 address & Content & \\
\hline
91 \begin{frame
}[fragile
]
92 \frametitle{SPLC has lambda functions through AST rewriting
}
93 \framesubtitle{\texttt{<LamdaExpr> ::= `
\textbackslash'<id>*
95 \begin{block
}{Implementation
}<
3->
96 Implemented by promoting lambdas to regular named functions
97 prior to semantical analysis.
100 \begin{column
}[T
]{0.5\textwidth}<
1->
103 map(
\x-> x+
1,
1:
2:
3:
[]);
107 \begin{column
}[T
]{0.5\textwidth}<
4->
113 map(
1lambda_
23,
1:
2:
3:
[]);
119 \item<
2-> SPLC supports anonymous lambda functions with arbitrary arity
120 \item<
2-> Lambdas are fully type checked, same as regular functions
124 \begin{frame
}[fragile
]
125 \frametitle{Syntactic sugar to ease our programmers lives
}
126 \begin{block
}{Global constants
}
128 \item SPLC does
\emph{not
} feature global variables.
130 \item We want to protect our users from global state (as much
133 \item Global constants allowed through
\texttt{Let
} statements
134 \item \texttt{<LetDecl> ::= `Let' <type> <id> `=' <Expr> `;'
}
135 \item Lets are rewritten to constant functions
138 \begin{column
}[T
]{0.4\linewidth}
143 \begin{column
}[T
]{0.4\linewidth}
145 x() :: Int
{ return
5;
}
152 \begin{frame
}[fragile
]
153 \frametitle{Syntactic sugar to ease our programmers lives
}
154 \framesubtitle{continued
}
155 \begin{block
}{String Literals
}
157 \begin{column
}[T
]{0.34\linewidth}
159 var a = "Hello world!";
162 \begin{column
}[T
]{0.5\linewidth}
164 var a = 'H':'e':'l':'l':'o':' ':
165 'w':'o':'r':'l':'d':'!':
[];
170 \begin{block
}{List Literals
}
172 \begin{column
}[T
]{0.34\linewidth}
177 \begin{column
}[T
]{0.5\linewidth}
184 \begin{block
}{Variable argument printing
}
186 \begin{column
}[T
]{0.34\linewidth}
191 \begin{column
}[T
]{0.5\linewidth}