handouts/amm-faq.tex
changeset 1017 b0d44eb1ecc7
parent 1016 c02d409ed7f4
equal deleted inserted replaced
1016:c02d409ed7f4 1017:b0d44eb1ecc7
    19 (Haoyi Li), it seems it has acquired some ``quirks'' when it
    19 (Haoyi Li), it seems it has acquired some ``quirks'' when it
    20 transitioned to Scala 3. Interestingly, the problems listed below only occur
    20 transitioned to Scala 3. Interestingly, the problems listed below only occur
    21 inside the REPL. So running Scala-scripts on the command
    21 inside the REPL. So running Scala-scripts on the command
    22 line with for example
    22 line with for example
    23 
    23 
    24 \begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small]
    24 \begin{lstlisting}[language={},numbers=none]
    25 $ amm cw02.sc
    25 $ amm cw02.sc
    26 \end{lstlisting} %% $
    26 \end{lstlisting} %% $
    27 
    27 
    28 \noindent
    28 \noindent
    29 works fine. Similarly, the original Scala REPL seems to not suffer 
    29 works fine. Similarly, the original Scala REPL seems to not suffer 
    74   //def ~ (r: String) = SEQ(s, r)
    74   //def ~ (r: String) = SEQ(s, r)
    75 }
    75 }
    76 \end{lstlisting}
    76 \end{lstlisting}
    77 
    77 
    78 \noindent You need to then use \code{&} in the code for the 
    78 \noindent You need to then use \code{&} in the code for the 
    79 \code{WHILE_REGS}
    79 \code{WHILE_REGS}.
       
    80 
       
    81 \subsection*{Problem with Loading Dynamically Files}
       
    82 
       
    83 There seems to be cache problems with loading dynamically files in the REPL.
       
    84 For example in the file \code{thompson.sc}, the code for DFAs, NFAs etc is 
       
    85 loaded using:
       
    86 
       
    87 \begin{lstlisting}[numbers=none,language=Scala]
       
    88 import $file.dfa, dfa._ 
       
    89 import $file.nfa, nfa._
       
    90 import $file.enfa, enfa._
       
    91 \end{lstlisting}%$
       
    92 
       
    93 \noindent The menace is that all works perfectly in the first REPL session,
       
    94 but if you close it and then re-open it for example the next day, you 
       
    95 receive the following error when you try to re-evaluate the same lines:
       
    96 
       
    97 \begin{lstlisting}[numbers=none,language=Scala]
       
    98 -- [E008] Not Found Error: ~/cfl-material/progs/automata/nfa.sc:50:2 
       
    99 50 |  dfa
       
   100    |  ^^^
       
   101    |  value dfa is not a member of ammonite.$sess - did you mean $sess.nfa?
       
   102 -- [E006] Not Found Error: ~/cfl-material/progs/automata/nfa.sc:6:18 
       
   103 6 |import $file.$  , dfa._ 
       
   104   |                  ^^^
       
   105   |                  Not found: dfa
       
   106   |
       
   107   | longer explanation available when compiling with `-explain`
       
   108 Compilation Failed
       
   109 \end{lstlisting}%$\medskip
       
   110 
       
   111 \noindent\textbf{Fix:} The code again runs absolutely fine when called on the
       
   112 commandline. But the REPL trips over. In this case, the trick with using the 
       
   113 Scala REPL does not work, because it does not support dynamically loading
       
   114 files. However, one ugly fix is to cut-and-paste all the code into a 
       
   115 single file and then develop this one gigantic file. Or a slightly
       
   116 less ugly solution is toi clear out the cache of ammonite. The cache
       
   117 on my system is located in 
       
   118 
       
   119 \begin{lstlisting}[language={},numbers=none]
       
   120 ~/.ammonite/cache/3.0.3/
       
   121 \end{lstlisting}
       
   122 
       
   123 \noindent
       
   124 I usually delete all files inside this directory and in this way force 
       
   125 ammonite to be in a consistent state.
    80 
   126 
    81 \end{document}
   127 \end{document}
    82 
   128 
    83 %%% Local Variables: 
   129 %%% Local Variables: 
    84 %%% mode: latex
   130 %%% mode: latex