[webkit-dev] Do we have a style preference about const member functions?
Peter Kasting
pkasting at google.com
Thu Jun 9 17:25:31 PDT 2011
On Thu, Jun 9, 2011 at 3:51 PM, Maciej Stachowiak <mjs at apple.com> wrote:
> In principle, the return value could have been retrieved from a container
> that the immediate callee only has a const reference to. So then casting
> away const on the return value would be a hazard.
>
You're right; if the implementation of the const function accesses other
objects besides |this|, it might be better to re-implement the non-const
function rather than simply casting, so the compiler can at least check
those accesses. This implies that in general we'd want to limit function
pairs to accessors with fairly simple implementations, and only make
exceptions where there's real value, lest the maintenance burden and bug
surface outweigh any gain from providing caller const convenience.
I'll try to keep this in mind before I try posting any patches that split
accessors into pairs.
PK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20110609/032d2dff/attachment.html>
More information about the webkit-dev
mailing list