我写了一点 Scala
object SquareNumbers extends App {
val numbers = List(1,2,3,4,5)
val squares = numbers map (i => i * i)
println (squares)
}
并scalac
像这样运行它:
$ scalac -Xprint:typer SquareNumbers.scala
[[syntax trees at end of typer]] // SquareNumbers.scala
package <empty> {
object SquareNumbers extends Object with App {
def <init>(): SquareNumbers.type = {
SquareNumbers.super.<init>();
()
};
private[this] val numbers: List[Int] = immutable.this.List.apply[Int](1, 2, 3, 4, 5);
<stable> <accessor> def numbers: List[Int] = SquareNumbers.this.numbers;
private[this] val squares: List[Int] = SquareNumbers.this.numbers.map[Int, List[Int]](((i: Int) => i.*(i)))(immutable.this.List.canBuildFrom[Int]);
<stable> <accessor> def squares: List[Int] = SquareNumbers.this.squares;
scala.this.Predef.println(SquareNumbers.this.squares)
}
}
我的问题是,输出中的<stable>
和是什么<accessor>
?他们叫什么(比如,他们有一个集体名词),他们做什么?
猜测一下,我会说这意味着它们是 vals 而不是 vars,并且意味着它是来自对象外部的可调用对象......