On 2018-01-19 18:32, Thiago Macieira wrote:
On Friday, 19 January 2018 09:26:10 PST Edward Welbourne wrote:
Jaroslaw Kobus (19 January 2018 17:09)

> "give" may be confused with "get", which is usually an accessor. I may
> also think "Am I giving (to QCoreApplication)" or "The
> QCoreApplication is giving (me)". Maybe it is just a matter of the
> other verb? Absorb, hand over, hand on, suck in, swallow...

However, we have plenty of take functions, where the caller takes
ownership from the object on which the method is called; so it makes
sense that a give function would be the caller giving ownership to the
object on wich the method is called.

Thus we'd keep child.setParent(newParent), since the child doesn't take
ownership of the parent; but QMainWindow's setCentralWidget() would
become giveCentralWidget(), matching its takeCentralWidget().  This
would save the search for its doc, to find that it does indeed take
ownership.

The signature is, in any case, always sufficient to make clear that a
give()r isn't a get()ter.

Let's stop the discussion about method *naming* right here. We're not going to
change hundreds of getters and setters now or even in Qt 6.

Let's instead find a solution that either uses macros or uses simple binary-
compatible pointer wrappers like GST.

And be careful with template functions. Changing from T to Something<T> may
change what gets deduced.


Nuno experienced a crash [1] which could have been easily caught by a compiler plugin or clang-tidy if we used gsl::owner or similar.

So to try to move things forward I asked Marc to restore his gsl::owner change [2].

I would recommend however that our docs show T* instead of gsl::owner<T> and continue to include "Takes ownership of foo" in the text. While I believe in self-documenting signatures I think it's too much noise and hurts readability, and most devs never heard of gsl.

Should be just an aid for tooling IMO.



[1] http://lists.qt-project.org/pipermail/interest/2018-July/030530.html
[2] https://codereview.qt-project.org/#/c/178107/

Regards,
--
Sérgio Martins | sergio.mart...@kdab.com | Senior Software Engineer
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel: Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - The Qt, C++ and OpenGL Experts
_______________________________________________
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to