[webkit-dev] Do we have a style preference about const member functions?

Brent Fulgham bfulgham at gmail.com
Tue May 31 17:55:12 PDT 2011


On Tue, May 31, 2011 at 4:37 PM, Maciej Stachowiak <mjs at apple.com> wrote:
> I agree that one useful distinction is whether a particular kind of object
> is every manipulated via const pointers or references. If we never use const
> references/pointers to a particular kind of object, then it is probably not
> useful to maintain const-correctness discipline for that class.

I don't agree with this.  I see no harm in maintaining const
correctness on objects, even if they are not currently manipulated
through const references/pointers.  They provide clear,
self-documenting evidence that the object design intends that certain
methods do not visibly alter the object.

I fail to see how abandoning const correctness can do anything but
cause us to start missing bugs that we would otherwise have found via
compiler errors.


More information about the webkit-dev mailing list