Clover2開発日誌

Clover2というJavaのように静的な型を持つRubyのようなコンパイラ+仮想マシンの開発日誌です。LLVMでJITもします。https://github.com/ab25cqにて開発しています。

version 3.2.1リリース

同一クラスのメソッドのself省略

> vim InternalMethodTest.clcl
class InternalMethodTest {
    def initialize() {}
    def method():int {
        return method2();
        # return self.method2()と書いても良い
    }
    def method2():int {
        return 123 
    }
}
> vim a.cl
a := new InternalMethod();
Clover.test("internal method test", a.method() == 123);
> clover2 a.cl
internal method test...OK

上記のような感じです。フィールドの方はselfは省略できません。エディッタでのフィールド名の置き換えで便利なので。あとはローカル変数とフィールド名がバッティングするのは良くないと思うためです。