[webkit-dev] On returning mutable pointers from const methods
koivisto at iki.fi
Thu Oct 25 07:15:53 PDT 2012
On Thu, Oct 25, 2012 at 1:48 PM, Andreas Kling <kling at webkit.org> wrote:
> So, I propose that we allow only these two signature formats for raw
> - const Foo* foo() const;
> - Foo* foo();
I think this would be an excellent rule to adopt for new code. The
mutable/immutable state pattern is a powerful way to optimize data
structures that are rarely mutated. Correct use of const through the code
makes using it much easier and safer. With adaption of PassRef/OwnPtr I
can't think of any correct uses for Foo* foo() const.
Moreover, for methods that return references to objects where call sites
> are expected to take a strong reference, we should really be using
> PassRefPtr<Foo> as the return type.
> Thoughts? Objections? Am I missing something?
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the webkit-dev