We at spark, have to customize scala repl to support our way of "code wrapping" for input code. The reason we want it that way is spark needs code serializable so that it can be executed on a remote worker.
I wish it was possible to configure rather than port scala repl code for every scala release migration. This pull request mayonly present my intention which is, we may not need a complete overhauling of scala REPL to support it and thus there should be a simpler solution to it. It also has a sample customization which uses class instead of object for wrapping code to be executed. The sample customization is exactly what we would need for spark i.e. serializable. Actually there is more space for making things in the repl customizable, but then this is just a beginning. This has been done in this particular way only to achieve the goal in minimal code change at expense of elegance. Of course suggestions and reviews comments are welcomed for me being on lurker side trying to step into space that might not be welcoming for its technical depth.
For Example
scala> val a = 10 a: Int = 10 scala> val b = a * 2 // show class $read extends Serializable { def <init>() = { super.<init>; () }; class $iwC extends Serializable { def <init>() = { super.<init>; () }; val $VAL1 = $line3.$read.INSTANCE; import $VAL1.$iw.$iw.a; class $iwC extends Serializable { def <init>() = { super.<init>; () }; val b = a * 2 }; val $iw = new $iwC.<init> }; val $iw = new $iwC.<init> } object $read extends scala.AnyRef { def <init>() = { super.<init>; () }; val INSTANCE = new $read.<init> } b: Int = 20 scala>
--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-interna...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.