News for hackers. Stuff that matters.
Re:C++0x (upcoming C++ standard, includes lambda functions) by plorkyeran on Wednesday August 11, 2010 @04:30PM (#1595998)
Requiring the use of templates (or std::function) is how closures work in C++ already. The new lambda syntax is just a (much) easier way to create closures, so it suffers from some of the same problems. I've never found wrapping things in std::function to be much of a problem, though.

You can "explicitly" pass all variables in the containing scope with [=] or [&], so it's more of an optional annotation than a requirement.

Re:C++0x (upcoming C++ standard, includes lambda functions) by makmanalp on Wednesday August 11, 2010 @05:33PM (#1596223)
I guess by making the closure explicit they've made implementing them much easier too. The problem of trying to figure out which variables the function is closed over is no longer there (which makes me curious because judging from my own experience in creating a scheme-clone, this wasn't that difficult). I bet it just transforms down into a function or maybe even gets inlined.