On December 4, 2015 16:10:56 Rafael Roquetto <[email protected]> wrote:
> On Fri, Dec 04, 2015 at 02:25:14PM +0100, Olivier Goffart wrote: >> On Friday 4. December 2015 14:11:48 Oswald Buddenhagen wrote: >> > On Fri, Dec 04, 2015 at 02:07:10PM +0100, Marc Mutz wrote: >> > > And as an aside, since it has been mentioned in this thread: in Python >> > > _all_ variables are 'auto'. All. Without exception. Are Python >> > > programmers more intelligent? Or do they just tolerate more pain? :) >> > >> > i'd suggest the latter. >> > no, really. people use external static checkers because the language >> > lacks the feature. >> > the lack of static typing is a common feature of scripting languages and >> > makes them convenient to a degree, but it is an utter nightmare for any >> > "real" software development. i really wouldn't want to go there. >> >> But auto is still staticaly typed. >> >> >> When you have code like >> >> foo->bar()->setFaz(m_factory->createFaz(foo->bar()->type())); >> >> You don't see any type. >> >> This code that use auto is not less readable. Even if you don't know what's >> the type of bar without looking it up. >> >> auto *bar = foo->bar(); >> bar->setFaz(m_factory->createFaz(bar->type())); > > Until you need to change your code and call any method of bar. Suppose I > need to change the following code, to print the first item of the collection: > > auto *bar = foo->collection(); > > /*TODO: print first item here */ > > model->setCollection(bar); // we know bar is a collection, but of what > kind? > > > Choose the right alternative: > > a) qDebug() << bar->first(); > b) qDebug() << bar->values().first(); > c) qDebug() << bar[0] > d) none of the above > > > To answer this, you will need to find out the return type of > Foo::collection(); The compiler knows it, but the reader does not. And the > answer depends on whether it is a QList/QVector, QHash/QMap, etc... Had it > been explicit, any programmer familiar with the Qt API (or any API in context) > would be able to directly write down the right statement. > The clang code model completes auto so it should be not that hard. Actually I would call an ordered map or unordered map a dictionary. > > Just an idea. > > Cheers, > Rafael > > -- > Rafael Roquetto | [email protected] | Software Engineer > Klarälvdalens Datakonsult AB, a KDAB Group company > Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322) > KDAB - Qt Experts Sent from cellphone _______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
