11 |
11 |
12 \section*{Scala in 6CCS3CFL} |
12 \section*{Scala in 6CCS3CFL} |
13 |
13 |
14 For the coursework in this module you are free to use any programming |
14 For the coursework in this module you are free to use any programming |
15 language you like, but I will show you all my code using Scala---I |
15 language you like, but I will show you all my code using Scala---I |
16 hope you have fond memories of Scala from PEP. But as said, you do not |
16 hope you have fond memories of Scala from PEP. If you need a reminder |
17 need to use Scala for your own code.\footnote{Haskell, Rust, Ocaml |
17 of the Scala handouts for PEP have a look |
18 were other languages that have been used previously in CFL. I |
18 \hr{http://talisker.nms.kcl.ac.uk/cgi-bin/repos.cgi/pep-material/raw-file/tip/handouts/pep-ho.pdf} |
19 recommend to not use Java or C for writing a compiler, but if you |
19 |
20 insist, feel free.} I will use the current stable version of |
20 |
21 Scala, which is 2.13.3. If you need a reminder of the Scala handouts |
21 But as said, you do not need to use Scala for your own |
22 for PEP have a look |
22 code.\footnote{Haskell, Rust, Ocaml were other languages that have |
23 \hr{http://talisker.nms.kcl.ac.uk/cgi-bin/repos.cgi/pep-material/raw-file/tip/handouts/pep-ho.pdf}\bigskip |
23 been used previously in CFL. I recommend to not use Java or C for |
|
24 writing a compiler, but if you insist, feel free. It has been done |
|
25 before.} I will use the |
|
26 current stable version of Scala, which is 2.13.6. For various reasons, |
|
27 I am NOT GOING TO USE THE LATEST VERSION OF SCALA 3.0! Please be |
|
28 aware of this when you run my code. |
|
29 \bigskip |
24 |
30 |
25 \noindent |
31 \noindent |
26 The main difference to the Scala I showed you in PEP is that in CFL |
32 The main difference to the Scala I showed you in PEP is that in CFL |
27 I will use the Ammonite REPL |
33 I will use the Ammonite REPL |
28 |
34 |
35 works very similarly, for example |
41 works very similarly, for example |
36 |
42 |
37 \begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small] |
43 \begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small] |
38 $ amm |
44 $ amm |
39 Loading... |
45 Loading... |
40 Welcome to the Ammonite Repl 2.2.0 (Scala 2.13.3 Java 9) |
46 Welcome to the Ammonite Repl 2.3.8 (Scala 2.13.3 Java 9) |
41 scala> 1 + 2 |
47 scala> 1 + 2 |
42 res0: Int = 3 |
48 res0: Int = 3 |
43 \end{lstlisting} %% $ |
49 \end{lstlisting} %% $ |
44 |
50 |
45 \noindent |
51 \noindent |
46 Ammonite uses the same Scala compiler, just adds some useful features |
52 Ammonite uses the same Scala compiler, just adds some useful features |