Coding standards proposal, usage of "this"

Simon Marchi simon.marchi@polymtl.ca
Mon Aug 16 16:59:34 GMT 2021


>>  - Use `this` when referring to a method of the current class.
>>    Rationale: without `this, it's not clear that you are referring to a
>>    method of the current class, versus a free function.
> 
> I'm not really a fan of this, and I am also not aware of other
> projects using such a style. Since this makes calling member functions
> more verbose/uglier than calling free functions, this would also
> discourage member functions. Is there a need to distinguish these?

There's no *need*, of course.  It's just based on my experience, I
remember seeing some function calls, wondering how it could even work
with the passed arguments.  And then I realized it was a method call,
where `this` is passed implicitly.

Do you think it would discourage adding member functions, in opposition
to adding free functions?  Or just leaving the code in-line, leading to
bigger methods?

Simon


More information about the Gdb-patches mailing list