Divecomputer nickname handling..

Linus Torvalds torvalds at linux-foundation.org
Thu Sep 17 15:30:41 PDT 2015


On Thu, Sep 17, 2015 at 3:18 PM, Tomaz Canabrava <tcanabrava at kde.org> wrote:
>
> move all members on the class to public access, then create static functions
> on the .cpp file like this:
>
> static void helper_function1(MyClass *self, var1, var2... ) {
> ...
> }

Yes, yes, I know this very well. And then you have that mixture of
explicit object pointers and implicit method member uses, and it just
confuses everybody because the "same" code ends up looking very
different indeed. It's detestable, and it makes it impossible to move
the *same* code out to a helper function: you basically have to edit
the end result so that it doesn't look at all the same as what it
would do inside the function.

.. and there's no reason for it. C++ should just have allowed private
static (or inlined) member functions that have to be resolved at
compile-time within that function and don't need declaration because
they don't have any external visibility and no possible virtual
entries.

You'd almost be better off just using "this->" everywhere, just to
have that consistent syntax.

And I really _detest_ changing header files for local re-organization.
It is just another reason C++ projects take forever to build - because
even local cleanups end up forcing a full rebuild just because you
ended up changing the member functions.

The last time this came up I think Thiago said that there's support
for it in the upcoming C++ standard. So _eventually_ you can just make
inlined helpers, I hope.

             Linus


More information about the subsurface mailing list