开发者

Is it possible for Scala to offer type checking inside scripts?

Does anyone know if there's a way to do have type checking in scripts for Scala? When I'm writing short scripts, I f开发者_Python百科eel I lose a lot of the strength of Scala's typechecking (i.e. catching errors when writing code, rather than when I try and compile).


See this fantastic answer by Miles Sabin; thanks to tenshi for pointing this out. You want to run

scala -Ystop:refchecks ScriptToCheck.scala

Success is indicated by this output:

java.lang.ClassNotFoundException: Main

I agree that it would be nice if a more user-friendly way were available (the -Y compiler options are quite arcane, and subject to change without notice; the success message belies the "hackishness" of this solution). But for the time being, you should be able to use this.

Hope I've been helpful.


If you use the Ecplise Scala IDE it supports incremental compilation, just like the JDT does for Java. This way, you get your red lights as you go.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜