私はピーター・ピルグリムです。Martin Odersky が Scala でコントロールの抽象化を作成するのを見ました。ただし、IntelliJ IDEA 9 内でそれを繰り返すことはまだできないようです。それは IDE ですか?
package demo
class Control {
def repeatLoop ( body: => Unit ) = new Until( body )
class Until( body: => Unit ) {
def until( cond: => Boolean ) {
body;
val value: Boolean = cond;
println("value="+value)
if ( value ) repeatLoop(body).until(cond)
// if (cond) until(cond)
}
}
def doTest2(): Unit = {
var y: Int = 1
println("testing ... repeatUntil() control structure")
repeatLoop {
println("found y="+y)
y = y + 1
}
{ until ( y < 10 ) }
}
}
エラーメッセージは次のとおりです。
情報: コンパイルは 1 つのエラーと 0 の警告で完了しました
情報: 1 つのエラー
情報: 0 の警告
C:\Users\Peter\IdeaProjects\HelloWord\src\demo\Control.scala
エラー: エラー: 行 (57) エラー: Control.this.型 Control.this.Until のrepeatLoop({
scala.this.Predef.println("found y=".+(y));
y = y.+(1)
}) はパラメータを取らない
repeatLoop {
カリー化された関数では、本体は式 (y+1 の値) を返すと考えられますが、repeatUntil の宣言本体パラメーターは、これを無視できるかどうかを明確に示していますか?
エラーの意味は何ですか?