[webkit-dev] Terminology for giving up ownership: take, release, move
mjs at apple.com
Wed Sep 7 01:57:21 PDT 2016
> On Sep 6, 2016, at 8:20 PM, Darin Adler <darin at apple.com> wrote:
>> On Sep 6, 2016, at 6:43 PM, Maciej Stachowiak <mjs at apple.com> wrote:
>> RefPtr does also have regular release() though. I'm not sure if this is for a practical reason or just no one has fixed it yet.
> It’s still around until we finish getting rid of PassRefPtr, that’s all.
>> A wacky solution, based on your suggestion for releaseImpl, would be to have a nonNull method which asserts the pointer is not null and then returns a self reference, so you'd do move(ref.nonNull()).
> I don’t think we can do that. I don’t know how to change a RefPtr<X> into a Ref<X>& in C++ even though we know the underlying object layout is identical.
I didn't notice that detail. In that case I'll just say that this non-central example shouldn't be a major consideration for naming data structure remove-and-get combo operations.
[It might be possible to make a way to convert a RefPtr<> to a Ref<> without refcount thrash that is closer to typical C++ conventions but I think suggestions along these lines are beyond my level of C++ knowledge. As a wild guess, perhaps a syntax like Ref<X> x = notNull(move(refPtr)) could be made to work.]
More information about the webkit-dev