On Wed, Apr 14, 2021 at 1:08 PM Leszek Swirski <lesz...@chromium.org> wrote:
> I would imagine this would be solvable by providing different overloads > for const and non-const operator-> (and operator*) in Handle. > That'd make both C'' and C''' behave like C (value member), but given their similarity to pointers it may make sense to have them behave like C' (pointer member). > > On Wed, Apr 14, 2021 at 11:51 AM 'Jakob Gruber' via v8-dev < > v8-dev@googlegroups.com> wrote: > >> 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. >> >> -- >> -- >> v8-dev mailing list >> v8-dev@googlegroups.com >> http://groups.google.com/group/v8-dev >> --- >> You received this message because you are subscribed to the Google Groups >> "v8-dev" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to v8-dev+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/v8-dev/CAH3p7oNJesNF0CuAsGe4O1UZoZGkio1ggZw_orGW3e4FLcTEhA%40mail.gmail.com >> <https://groups.google.com/d/msgid/v8-dev/CAH3p7oNJesNF0CuAsGe4O1UZoZGkio1ggZw_orGW3e4FLcTEhA%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- > -- > v8-dev mailing list > v8-dev@googlegroups.com > http://groups.google.com/group/v8-dev > --- > You received this message because you are subscribed to the Google Groups > "v8-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to v8-dev+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/v8-dev/CAGRskv-jeyZU1eTq1Bxk9FzLOQ%2BPDDP97hDU_PHghkUQFb6Fkg%40mail.gmail.com > <https://groups.google.com/d/msgid/v8-dev/CAGRskv-jeyZU1eTq1Bxk9FzLOQ%2BPDDP97hDU_PHghkUQFb6Fkg%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- -- v8-dev mailing list v8-dev@googlegroups.com http://groups.google.com/group/v8-dev --- You received this message because you are subscribed to the Google Groups "v8-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/CAH3p7oOaPXJVD__SJ0%3DrTYnH%3DpRMBOB3j1MdU%2BHmL7i%2BfPXwvw%40mail.gmail.com.