謎's キッチン

謎のひとりごと。Amazon欲しい物リストはこちら: https://www.amazon.co.jp/hz/wishlist/ls/CCPOV7C6JTD2

DMD 2.013 ktkr

opDotの実装の仕方がちょっと想定外だった。alias thisの代わりになったのかな。派生時に異なるのでalias thisの方が良いと思った(以下)。あと最適化がちゃんとされるか。

import std.stdio;
interface I{
  int x();
}

class A{
  int x(){return 0;};
}

class B:I{//エラー
  A a;
  this(){
    a = new A;
  }
  A opDot(){
    return a;
  }
}

void main(){
  auto b = new B;
  writefln(b.x());
}

thread storageがきてる。
(結果的かもしれないが)Delphiを意識した更新になってる気がした。