相关疑难解决方法(0)

scala编译器阶段的顺序是什么?

我想要提高我对scala编译阶段的描述.我知道某些事情必须在编译器中发生,但实际上并不知道它们发生的顺序以及顺序如何影响我的编程.

我是否正确地说以下内容是编译器的完整列表?

  • 解析程序
  • 检查类型
  • 擦除
  • 隐式转换
  • 生成字节码
  • 优化

如果是这样,那么这些阶段的顺序是什么?这个命令如何影响程序员,尤其是类型级程序员?

compiler-construction scala scalac

22
推荐指数
2
解决办法
3879
查看次数

为什么Scala的分号推断在这里失败?

在使用Scala 2.7.3编译以下代码时,

package spoj

object Prime1 {
  def main(args: Array[String]) {
    def isPrime(n: Int) = (n != 1) && (2 to n/2 forall (n % _ != 0))
    val read = new java.util.Scanner(System.in)
    var nTests = read nextInt // [*]
    while(nTests > 0) {
      val (start, end) = (read nextInt, read nextInt)
      start to end filter(isPrime(_)) foreach println
      println
      nTests -= 1
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我得到以下编译时错误:

PRIME1.scala:8: error: illegal start of simple expression
    while(nTests > 0) {
    ^
PRIME1.scala:14: error: …
Run Code Online (Sandbox Code Playgroud)

scala

16
推荐指数
3
解决办法
2611
查看次数

为什么在进程后需要一个空行(aString)!在斯卡拉?

当我运行外部进程时,看起来我们需要在调用后添加一个空行.为什么会抛出那个错误?

 class JobActor extends Actor {
  def receive = {
    case msg:String =>
       Process(msg)!
                       // here need a blank line, otherwise it throws error 
       sender ! "complete"
  } 
}
Run Code Online (Sandbox Code Playgroud)

错误是

[error]  found   : akka.actor.ActorRef
[error]  required: scala.sys.process.ProcessLogger
[error]        sender ! "complete"
[error]        ^
[error] one error found
Run Code Online (Sandbox Code Playgroud)

scala

3
推荐指数
1
解决办法
176
查看次数

标签 统计

scala ×3

compiler-construction ×1

scalac ×1