[webkit-dev] Do we have a style preference about const member functions?
Brent Fulgham
bfulgham at gmail.com
Wed Jun 1 14:27:18 PDT 2011
On Tue, May 31, 2011 at 11:31 PM, Maciej Stachowiak <mjs at apple.com> wrote:
> [...] What do you believe is the proper const-correct way to write previousSibling() and related methods?
> A priori, I think the correct way is this:
>
> Node* previousSibling() { return m_previous; }
>
> I could also be convinced that the following is technically more correct, though in a way that is completely
> useless for our code base at present:
>
> const Node* previousSibling() const { return m_previous; }
> Node* previousSibling() { return m_previous; }
>
> What do you think is the right way to do it? One of these? Something else?
> [...]
> Well one big problem right now (just from scanning the core DOM classes) is that we have a lot of clearly
> broken use of const. We could (a) leave it as-is, (b) remove the incorrect use of const, or (c) deploy proper
> const-correctness. it seems like you are against (b), but I cannot tell if you advocate (a) or (c).
I would *prefer* to deploy proper const correct accessors, so (c).
However, in the interests of pragmatism I think that it would be
reasonable to at least remove the improper uses of const (b).
>From the tone of the initial e-mail it sounded like there was some
desire to get rid of const declarations across the board. I would be
opposed to this change. However, I concede that improper use of const
is worse than no const declaration, and would support your (b) case
(though I would prefer (c)!).
-Brent
More information about the webkit-dev
mailing list