# HG changeset patch # User Christian Urban # Date 1761299117 -3600 # Node ID b0d44eb1ecc723987c95c10018a001fb35603059 # Parent c02d409ed7f40f65104697906f900a0214ec940f updated diff -r c02d409ed7f4 -r b0d44eb1ecc7 handouts/amm-faq.pdf Binary file handouts/amm-faq.pdf has changed diff -r c02d409ed7f4 -r b0d44eb1ecc7 handouts/amm-faq.tex --- a/handouts/amm-faq.tex Fri Oct 24 08:55:14 2025 +0100 +++ b/handouts/amm-faq.tex Fri Oct 24 10:45:17 2025 +0100 @@ -21,7 +21,7 @@ inside the REPL. So running Scala-scripts on the command line with for example -\begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small] +\begin{lstlisting}[language={},numbers=none] $ amm cw02.sc \end{lstlisting} %% $ @@ -76,7 +76,53 @@ \end{lstlisting} \noindent You need to then use \code{&} in the code for the -\code{WHILE_REGS} +\code{WHILE_REGS}. + +\subsection*{Problem with Loading Dynamically Files} + +There seems to be cache problems with loading dynamically files in the REPL. +For example in the file \code{thompson.sc}, the code for DFAs, NFAs etc is +loaded using: + +\begin{lstlisting}[numbers=none,language=Scala] +import $file.dfa, dfa._ +import $file.nfa, nfa._ +import $file.enfa, enfa._ +\end{lstlisting}%$ + +\noindent The menace is that all works perfectly in the first REPL session, +but if you close it and then re-open it for example the next day, you +receive the following error when you try to re-evaluate the same lines: + +\begin{lstlisting}[numbers=none,language=Scala] +-- [E008] Not Found Error: ~/cfl-material/progs/automata/nfa.sc:50:2 +50 | dfa + | ^^^ + | value dfa is not a member of ammonite.$sess - did you mean $sess.nfa? +-- [E006] Not Found Error: ~/cfl-material/progs/automata/nfa.sc:6:18 +6 |import $file.$ , dfa._ + | ^^^ + | Not found: dfa + | + | longer explanation available when compiling with `-explain` +Compilation Failed +\end{lstlisting}%$\medskip + +\noindent\textbf{Fix:} The code again runs absolutely fine when called on the +commandline. But the REPL trips over. In this case, the trick with using the +Scala REPL does not work, because it does not support dynamically loading +files. However, one ugly fix is to cut-and-paste all the code into a +single file and then develop this one gigantic file. Or a slightly +less ugly solution is toi clear out the cache of ammonite. The cache +on my system is located in + +\begin{lstlisting}[language={},numbers=none] +~/.ammonite/cache/3.0.3/ +\end{lstlisting} + +\noindent +I usually delete all files inside this directory and in this way force +ammonite to be in a consistent state. \end{document}