
diff -r 184a13ff50ed -r 4b3489012ac0 handouts/amm-faq.tex
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/handouts/amm-faq.tex	Fri Oct 24 08:55:14 2025 +0100
@@ -0,0 +1,86 @@
+\documentclass{article}
+\usepackage{../style}
+\usepackage{../langs}
+\usepackage{marvosym}
+\usepackage{tcolorbox}
+%% \usepackage[]{hvextern}
+
+%cheat sheet
+%http://worldline.github.io/scala-cheatsheet/
+
+\begin{document}
+\fnote{\copyright{} Christian Urban, King's College London, 2025}
+
+\section*{Ammonite ``Quirks''}
+
+While Ammonite is great when it comes to additional features, such as
+multiple main's and dynamically loading files, and in the past it was
+a rock-solid piece of software written by one of my Scala-heroes
+(Haoyi Li), it seems it has acquired some ``quirks'' when it
+transitioned to Scala 3. Interestingly, the problems listed below only occur
+inside the REPL. So running Scala-scripts on the command
+line with for example
+
+\begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small]
+$ amm cw02.sc
+\end{lstlisting} %% $
+
+\noindent
+works fine. Similarly, the original Scala REPL seems to not suffer 
+from these quirks. Unfortunately, this REPL does not allow you to
+dynamically load files which might be relevant in later CWs.
+
+\subsection*{Problem with Implicits}
+
+In CW2 (and possibly others), if you use the template code and develop
+your code inside the REPL, a problem arises in the line
+
+\begin{lstlisting}[numbers=none,language=Scala]
+val KEYWORD : Rexp = "while" | "if" | "then" 
+\end{lstlisting}
+
+\noindent with the error
+
+\begin{lstlisting}[numbers=none,language=Scala]
+-- [E008] Not Found Error: cmd17.sc:1:36 -----------------------------
+1 |val KEYWORD : Rexp = "while" | "if" | "then" 
+  |                     ^^^^^^^^^^^^^^^^
+  |value | is not a member of ammonite.$sess.cmd4.ALT.
+  |An extension method was tried, but could not be fully constructed:
+  |
+  |    ammonite.$sess.cmd16.|()
+  |
+  |    failed with:
+  |
+  |        value |: <overloaded ammonite.$sess.cmd16.|> does not take 
+  |        parameters
+  |Compilation Failed
+\end{lstlisting}%$\medskip
+
+
+\noindent\textbf{Fix:} The code runs absolutely fine when called on the
+commandline. It also runs absolutely fine inside the standard Scala REPL.
+If you prefer to use to use the Ammonite REPL, then you need to make the 
+following changes: (1) comment out the implicits below and change the 
+\code{$} to for example \code{&}%$:
+
+\begin{lstlisting}[numbers=none,language=Scala]
+extension (s: String) {
+  def & (r: Rexp) = RECD(s, r)
+  //def | (r: Rexp) = ALT(s, r)
+  //def | (r: String) = ALT(s, r)
+  //def % = STAR(s)
+  //def ~ (r: Rexp) = SEQ(s, r)
+  //def ~ (r: String) = SEQ(s, r)
+}
+\end{lstlisting}
+
+\noindent You need to then use \code{&} in the code for the 
+\code{WHILE_REGS}
+
+\end{document}
+
+%%% Local Variables: 
+%%% mode: latex
+%%% TeX-master: t
+%%% End: 




