[Qt5-feedback] Lambdas

Thiago Macieira thiago at kde.org
Wed Jun 29 23:37:31 CEST 2011


Em Wednesday, 29 de June de 2011, às 22:26:13, Robin Burchell escreveu:
> On 29 June 2011 20:54, Thiago Macieira <thiago at kde.org> wrote:
> > Em Wednesday, 29 de June de 2011, às 21:27:57, Konrad Rosenbaum escreveu:
> >> if(mylist.contains( [](mydata&dat){return dat.name=="hello";} ) )
> >>   doSomething()
> > 
> > Like I said, this is a job for external functions, like qFind or STL
> > algorithms.
> 
> Why? I'm not sure I agree. Qt exists to make developers' lives easier,
> and even at the Qt3 -> Qt4 transition, when STL was fairly mature on
> many platforms, Qt kept their own container classes (for which I am
> very thankful, as they tend to provide a bit more convenience,
> although a lot of that is things like implicit sharing to make writing
> methods returning complex containers easier and foreach - for
> instance). And isn't this exactly what things like this are about?
> Convenience?
> 
> If STL provides the same functionality in its basic containers, that's
> great, but we shouldn't limit ourselves to someone else's subset of
> functionality, should we?

I'm not saying anything about the STL containers, I'm saying we should use the 
STL algorithm functions that perform those tasks. We should even implement our 
functions as wrappers to the STL ones if possible, as the compiler writers 
probably did the best job possible.

Unlike the containers, where we disagree on some basic functionality 
semantics, there aren't many ways to implement a linear search or a binary 
search. So why not use the STL functions there?

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt.nokia.com/pipermail/qt5-feedback/attachments/20110629/8c5add60/attachment-0001.bin 


More information about the Qt5-feedback mailing list