Merge branch 'master' of https://github.com/dopefishh/cc1516
[cc1516.git] / deliverables / report / sem.tex
index fde8f01..f63a32e 100644 (file)
 %the team.
 
 \newcommand{\unif}{{\scriptscriptstyle\cup}}
+%\subsubsection{Anonymous functions}
+%When the programmers wants to use small functions that consist of one line to
+%for example use the operators in a functional way the programmer has to make a
+%named function for every operator. In some cases it is easy to do this inline
+%using anonymous functions. A small syntactic sugar has been added that will
+%inline anonymous functions to non-anonymous functions during the parsing phase.
+%The following snippet is an example of a filter on even values before and after
+%transformation.
+%
+%\begin{SPLCode}
+%//Before transformation
+%main(){
+%      var a = filter(\x->x % 2 == 0, 1 : 2 : 3 : 4 : 5 : []);
+%}     
+%
+%//After transformation
+%1lambda_23(x){
+%      return x % 2 == 0;
+%}
+%
+%main(){
+%      var a = filter(1lambda_23, 1 : 2 : 3 : 4 : 5 : []);
+%}     
+%\end{SPLCode}
+
+Every anonymous functions gets a unique name outside the namespace of legal
+names for functions making sure the name is unique. By implementing the
+transformation in the parsing phase the function is automatically checked
+or inferred on type.
 
 The semantic analysis phase asses if a -grammatically correct- program is also
 semantically correct and decorates the program with extra information it 
@@ -370,4 +399,4 @@ blabla, verschil tussen wel en niet iets returnen
                        (\Gamma^\star, \star, \tau, \underline{\textrm{return }} e')
                }
                {\Gamma \vdash e \Rightarrow (\Gamma^\star, \star, \tau, e')}
-\end{equation}
\ No newline at end of file
+\end{equation}