On Tue, Dec 23, 2014 at 10:14 AM, L. David Baron <dba...@dbaron.org> wrote:

> On Tuesday 2014-12-23 09:59 -0800, Martin Thomson wrote:
> > On Tue, Dec 23, 2014 at 9:55 AM, L. David Baron <dba...@dbaron.org>
> wrote:
> > >
> > > But that's an implicit constructor that's causing extra refcount
> > > traffic, which is one of the things we didn't want here.
> >
> >
> >
> > I don't think that it's quite fair to complain about implicit conversion
> if
> > the whole point is to enable implicit conversion of another sort.  And
> > maybe something could be done about the refcount traffic.
>
> The problem is that something unexpected is happening.  People
> should expect the implicit conversions that are part of the
> language.  They generally don't expect implicit creation of smart
> pointers to cause reference counting traffic when they make a
> function call.
>
> Implicit conversions can be useful when they're carefully designed.
> But C++ makes it too easy to create them by accident (by making
> 1-parameter constructors do implicit conversion by default).  And
> this one doesn't look carefully designed, given that it does things
> that users don't expect, and it's not clear how to fix that.


Just to be clear, is your problem the implicit conversion itself
or the reference count increment/decrement?

On the specific topic of what users expect, what you expect may not
be what I expect, but I would observe that both C++11 shared_ptr
and Boost intrusive_ptr (the analog to our RefPtrs> automatically
convert from SmartPtr<Derived> to SmartPtr<Base> and appear to
increment the reference count in the same way that RefPtr does;
this seems to suggest that at least some people do expect it to
behave this way.

-Ekr
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to