|
Boost : |
Subject: Re: [boost] [local] Review
From: Robert Ramey (ramey_at_[hidden])
Date: 2011-11-21 11:04:10
Hartmut Kaiser wrote:
> What exactly is missing from C++11 lambdas for them to be useful as
> local functions?
>
> void foo()
> {
> auto f = [](){ cout << "Hey, I'm a local function!\n"; }
> f();
> }
>
> Why do we need Boost.Local instead?
>
I've looked a a few posts on this thread and I think I see
what the issue is.
a local function is something that almost any C program
can understand without embarking on a significant
amount of study to understand a whole new syntax. The
functionality is transparent and verifiable to anyone who
looks it. This is true even though its more verbose.
(or maybe its true BECAUSE it's more verbose.)
When I see
auto f = [](){ cout << "Hey, I'm a local function!\n"; }
Now I have to embark upon a mini-research project
to learn of bunch of new stuff that I didn't know before
in order to do something that could easily be done
the "old fashioned" way. OK you say I should bone
up on the new stuff anyway. Maybe, but in reality
there's a couple of other things going on.
a) in my company we might not be using a compiler which
supports these latest features.
b) I maybe under huge pressure to address something
before business opens tomorrow (this is common for me).
So I don't have time for an un-anticipated diversion.
c) When In insert something like this, it will eventually
get reviewed by other programmers who really need to
be able to understand something right away when they
look at it.
So I don't seen any real conflict between the local function
lambda one. I've I'm crafting the next greatest boost library
where I have as much time as necessary to get it exactly
optimal I might use one while under other circumstances
I might prefer something that everyone can swallow without
problem.
Robert Ramey
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk