Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save REPL session?

Is it possible to save a REPL session in a file? Is there a minimum version of Scala requiered to do this? I remember having seen someone do it, but I can't fine it in :help or in the documentation.

like image 438
OlivierBlanvillain Avatar asked Feb 28 '14 20:02

OlivierBlanvillain


1 Answers

This is possible as of Scala 2.11. Example usage:

scala> 1
res0: Int = 1

scala> 2
res1: Int = 2

scala> 3
res2: Int = 3

scala> :save xxx

scala> :load xxx
Loading xxx...
res3: Int = 1
res4: Int = 2
res5: Int = 3

You can :reset before a :load to get correct references to results:

scala> 1
res0: Int = 1

scala> res0 + 1
res1: Int = 2

scala> :save xxx

later that day...

scala> 7
res0: Int = 7

scala> :reset
Resetting interpreter state.
Forgetting this session history:

7

Forgetting all expression results and named terms: $intp

scala> :load xxx
Loading xxx...
res0: Int = 1
res1: Int = 2
like image 144
som-snytt Avatar answered Sep 20 '22 19:09

som-snytt