Hi team,
I came across this yesterday and found the behavior surprising, thus this quick fyi email.
`Handle<Object>` and `Object` class members have different behavior wrt to const. The former behaves like a plain old C++ pointer (`ClassXYZ*`) while the latter behaves like an instance (`ClassXYZ`). This is a bit strange, since conceptually both `Handle<Object>` and `Object` otherwise behave like pointers underneath (e.g. `Object x; x = y;` is a reference copy, not a value-copy).
Examples:
class C {
void foo() const { x_.nonconst_function(); } // compile-time error.
ClassXYZ x_;
}
class C' {
void foo() const { x_->nonconst_function(); } // okay.
ClassXYZ* x_;
}
class C'' {
void foo() const { x_.nonconst_function(); } // compile-time error.
Object x_;
}
class C''' {
void foo() const { x_->nonconst_function(); } // okay.
Handle<Object> x_;
}
While not terribly important, equal behavior between Object and Handle<Object> would be more consistent.