In Intellij Scala Worksheet support, what is the difference between the Run types i.e PLAIN vs REPL ?
Plain
evaluation model compiles the whole worksheet in one go before evaluating expressions, whilst REPL
evaluation model evaluates each expression on the go before moving to the next one.
Adding an expression in REPL
mode evaluates incrementally just that new expression, whilst in Plain
mode it would re-interpret the whole worksheet from the beginning.
An example where the difference matters is when defining companion objects. Similarly to how in Scala REPL proper we have to use :paste
command to define companion, in IntelliJ Scala Worksheet we have to use Plain
run type.