__vptr (invariant(void*)*)と__monitor (void*)。
module test; import std.stdio; class Foo{ int x=10; int baz(){return x;} } class Bar{ int x=10; int baz(){return x+10;} } void main(){ auto foo = new Foo; (cast(void function(Foo f))foo.__vptr[1])(foo); // foo.print // "test.Foo" writefln((cast(int function(Foo f))foo.__vptr[Object.classinfo.vtbl.length])(foo)); // foo.baz auto bar = new Bar; foo.__vptr = bar.__vptr; foo.print(); // "test.Bar" writefln(foo.baz()); synchronized(foo) writefln(foo.__monitor); }
配列演算実装途中?
import std.stdio; void main(){ double[2] a = [1,2], b = [2,3], c = [0,0]; c[] = a[] + b[]; // リンカエラー writefln(c); }
コード修正しまくり。