Boost logo

Boost :

Subject: Re: [boost] New libraries implementing C++11 features in C++03
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2011-11-23 05:04:01


On Tue, Nov 22, 2011 at 9:21 PM, Joel de Guzman
<joel_at_[hidden]> wrote:
> Local cannot be an approximation of lambda. As mentioned again and again,

I said this many times before but I feel I should have repeated myself
here in my previous reply. Yes you are correct, Locals are not an
approximation of lambdas because they cannot be defined within
expressions (which is a fundamental defining feature of lambdas).

Locals instead define closures at local statement scope, they use
statement syntax to implement the function body, they work on both
C++03 and C++11, they have compile and run-time performances similar
to the ones of C++11 lambdas on C++11 compilers (wow, that's a long
sentence but I think it summarizes everything :) ).

> a good approximation of lambda is already existing in Boost. Namely: bind,
> lambda and phoenix. I posted a Spirit example of lambda in action using
> Phoenix:
>
>  http://tinyurl.com/7w2h2r9
>
> Try as hard as you can, but you cannot ever come close to the clarity of
> the syntax presented there. Proponents of locals have cited error-messages
> generated by the compiler as a justification for Locals. Locals is probably
> a good workaround. But hear me out...

--Lorenzo


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk