From 898df0d6d0e370b8e4c77aee3edd29355a43d022 Mon Sep 17 00:00:00 2001 From: pimjager Date: Fri, 17 Jun 2016 12:58:02 +0200 Subject: [PATCH] s --- deliverables/report/sem.tex | 3 ++- examples/old/simpleReport.spl | 6 ++++++ examples/passBy.spl | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 examples/old/simpleReport.spl create mode 100644 examples/passBy.spl diff --git a/deliverables/report/sem.tex b/deliverables/report/sem.tex index cddc19b..8ff63cc 100644 --- a/deliverables/report/sem.tex +++ b/deliverables/report/sem.tex @@ -217,7 +217,8 @@ type and a field selector to a new type: $\texttt{apfs} : \tau \times \textit{fieldselector} \rightarrow \tau$. Note that the inference rule only checks if a field selector can be applied on -a certain type, and does not use the field selector to infer the type. This means that a program: \tt{f(x)\{ return x.hd; \}} can not be typed, and instead +a certain type, and does not use the field selector to infer the type. This +means that a program: \tt{f(x)\{ return x.hd; \}} can not be typed, and instead \tt{f} must be explicitly typed as \tt{:: [a] -> a} (or something more specialised) by the programmer. This could be improved by changing the \tt{apfs} function to infer for type variables. diff --git a/examples/old/simpleReport.spl b/examples/old/simpleReport.spl new file mode 100644 index 0000000..aa47c6d --- /dev/null +++ b/examples/old/simpleReport.spl @@ -0,0 +1,6 @@ +plus(x,y) { + return x + y; +} +main() { + var x = plus(3, 4); +} \ No newline at end of file diff --git a/examples/passBy.spl b/examples/passBy.spl new file mode 100644 index 0000000..552eabe --- /dev/null +++ b/examples/passBy.spl @@ -0,0 +1,34 @@ +//modify1(s) :: [Char] -> [Char] { +// //s.hd = 'a'; +// s.tl = []; +// return s; +//}// + +//modify2(c) :: Char -> Void { +// c = 'a'; +//}// + +//main() { +// var zs = "bar"; +// var zc = 'b'; +// var zss = modify1(zs); +// modify2(zc);// + +// print("zs was bar, is now: "); +// print(zs); +// print(", m1 returned: "); +// print(zss); +// print("\n"); +// print("zc was 'b', is now: ", zc, "\n"); +//} + +modi(t) :: (Int,Int) -> Void { + t.fst = 1; +} + +main() { + var x = (2,3); + print(x.fst); + modi(x); + print(x.fst); +} \ No newline at end of file -- 2.20.1