[Development] Proposal: Deprecating platforms in Qt 5.6 that don't support lambda

Bo Thorsen bo at vikingsoft.eu
Fri Feb 20 09:03:40 CET 2015


On 02/19/2015 09:41 PM, Matthew Woehlke wrote:
> On 2015-02-19 15:21, Marc Mutz wrote:
>> On Thursday 19 February 2015 13:29:48 Daniel Teske wrote:
>>> more than 400 lambdas in Creator's source
>>
>> Sounds like lambdas are overused (as any new language feature is overused
>> before it's fully understood by the resp. language community).
>
> Maybe, maybe not.
>
> I'm not sure I've even *written* 400 lambdas yet :-), but I find myself
> using them most often in QObject::connect. Basically, a lambda saves
> writing a protected (or worse, *private*) slot by allowing the relevant
> code to be written inline. These are rarely more than a few lines long,
> and it's not unusual for them to be one-liners, e.g.:
>
>    connect(d->UI.scrollBar, &QAbstractSlider::valueChanged,
>            [d](int value){ d->scrollTo(value); });
>
> The above is basically a private slot that's *actually private*. I've
> also had cases of needing to connect a signal to a slot where the slot
> needs to be called with additional (constant) arguments; these tend to
> look like the above also.

This is also how I tend to use lambdas, and I agree they are great. 
Especially for network requests, they are so much better than the old 
style code.

But this is an implementation convenience only. You can't convince me to 
drop VS2010 to be able to use them internally inside Qt. Or 2008 for Win 
CE or old gcc for blackberry or one of all the other answers that have 
been given in those threads over the last couple of weeks.

Andrés question about how this would change the API is a lot more 
interesting. I so far haven't seen a single case where someone has 
described how access to lambdas might improve the API. If they are 
there, I'd love to see them, because maybe this would teach me something 
I haven't figured out yet.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu



More information about the Development mailing list