On Sat, 2016-08-13 at 16:27 +0200, Tavmjong Bah wrote:
I started to think about this as I noticed in the code some
places with perhaps over aggressive use of 'auto'. It seems to me that
'auto' should be reserved to places where it replaces a long, already
unreadable iterator type. But it should not be used to replace simple
types as this reduces the readability of the code, especially to
someone not familiar with the code. For example, I don't see any
benefit of replacing:
GtkWidget* mywidget = someFunction();
by
auto* mywidget = someFunction()
My thoughts on this are when the type is clear, it's good to use auto to avoid duplication. When the type is not, it makes things harder to figure out. So for instance this is a good use:
auto foo = gtk_box_new();
But this would be bad:
auto foo = doStuff();
But that also goes for naming the varriable, as this would make sense to me:
auto doStuffSuccessful = doStuff();
So it is largely a feeling thing, I think it is useful but I also think it can be overused.
Ted