Bridgewater / scala-notebook

Interactive Scala REPL in a browser
Other
741 stars 155 forks source link

Specifying custom kernel.classpath causes kernels to fail to start, due to classpath error #12

Closed chrismyang closed 11 years ago

chrismyang commented 11 years ago

If you specify a kernel.classpath as a configuration, it ends up setting the entire kernel classpath to exactly what you set kernel.classpath to, instead of kernel.classpath + default.

The culprit appears to be this line, which looks quite reasonable but actually does not do what you want.

As a simple test case, try these two snippets in your REPL of choice (perhaps Scala Notebook itself, perhaps?):

Some(List("foo")) getOrElse(Nil) :+ "bar"
=> List(foo)

while

Some(List("foo")).getOrElse(Nil) :+ "bar"
=> List(foo, bar)

Someone smarter and Scala-ier than me can probably explain to me why the extra dot causes the parser to do something different, but I am struck, once again, by the danger of using operator-style (i.e., dot-less) invocation of methods.

chrismyang commented 11 years ago

Ah, if I had to hazard as a guess as to what the parser is doing, it looks like it's evaluating (Nil) :+ "bar" as parameter to the getOrElse.

Hm, how 'bout that.

Pull request submitted.

copumpkin commented 11 years ago

They've actually made dot-less invocation an "optional language feature" in 2.10 now, so you aren't the only one to think it's unsafe. I try to avoid that style wherever possible, except with symbolic operators.

copumpkin commented 11 years ago

I think this is fixed now.