Feeds

back to article C++ Futures: Lambda Functions

The use of “lambda” originates from functional programming and lambda calculus, where a lambda abstraction defines an unnamed function. Lambda functions or Lambdas in C++ are one of the more interesting things to look forward to in the next C++ standard; giving us the ability to treat functions as first class objects at last; …

COMMENTS

This topic is closed for new posts.

Unreadable syntax

While lambdas are undoubtably a boon to C++ (or any other language that don't already have them), I find the syntax to be unreadable. This may be because I find C++ syntax in general to be horrible, but for comparison you should look at languages like Haskell or SML. I'm not saying that the syntax of these langauges can not be improved, but they are a damn sight more readable than C++ -- lambdas or no lambdas.

0
0
Anonymous Coward

You're not hired

Your first example:

void KillByVal(const int x , std::vector<int> & Vec) {

std::remove_if(v.begin(), v.end(), bool (int& n) { n == x; }

};

The remove_if is missing the closing ')'.

Function definitions should not have a ';' after the closing '}'.

0
0

Boost Phoenix?

Have you seen Boost.Spirit's Phonix lambda interface?

http://spirit.sourceforge.net/distrib/spirit_1_7_0/libs/spirit/phoenix/index.html

That enables you to do pretty much what you want to do with the futures or lambda given the current C++ implementation.

0
0
This topic is closed for new posts.