In Intellij Scala Worksheet support, what is the difference between the Run types i.e PLAIN vs REPL ?
2 Answers
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.

- 47,285
- 6
- 56
- 98
REPL
mode as it says READ EVALUATE PRINT LOOP
is kind of interpreter i.e. each expression will be evaluated after to move to next line.. It is generally used to make quick logic checks
.
while in worksheet
mode you need to make an object or class.. worksheet is the traditional OOPS way like we do in java and whole file is compiled in one go
.

- 27
- 9