[webkit-dev] On returning mutable pointers from const methods

Peter Kasting pkasting at chromium.org
Sun Oct 28 22:32:37 PDT 2012


On Sun, Oct 28, 2012 at 3:12 PM, Filip Pizlo <fpizlo at apple.com> wrote:

> The point is that a rule mandating const methods to return const pointers
> prevents me from saying that getting a pointer from a container doesn't
> change the container.
>

Um, yes, that's exactly the point.  My argument was that it's very rare
that such pointers cannot be used to subsequently affect state visible to
the container.

Hence with any such rule in place you risk there being fewer uses of const.
>

I don't think anyone is handing out bonuses for the number of times we use
the const qualifier.  Removing physically-but-not-logically-const uses of
const is a win in my book, not a loss.  Converting to
definitively-const-safe functions (i.e. const T* foo() const), or failing
that pairs of accessors (one const, one non-const), is even better.

PK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20121028/016cb8da/attachment-0001.html>


More information about the webkit-dev mailing list