Darren New wrote:
Christopher Smith wrote:
You may now commence griping about how C++ sucks, is overly complex,
and these changes only make it worse.
Are these really closures? I don't see in any of the examples unbound
variables. Not that you couldn't do it with proper compiler support,
but the examples shown certainly aren't showing off (say) storing a
closure in a global, returning from the function that created it, then
accessing the local variables from the function that created the closure.
The article links to the actual standard, which includes this example of
the syntax in the introduction:
double min salary = ....
....
double u limit = 1.1 min salary;
std::find if(employees.begin(), employees.end(),
[&](const employee& e) { return e.salary() >= min salary && e.salary() <
u limit; });
One thing the C++0X folks wouldn't do would be to use the term
"closurely" loosely.
Note that later versions of C# handle this by basically making an
anonymous class and copying the local variables into it, letting you
nest closures and functions while returning them from the creating
function. So maybe C++ does this. But it certainly isn't obvious from
this article.
I haven't fully digested the standards document, but it appears to allow
this method or the "hold on to a pointer to the frame" approach, at the
runtime's discretion.
--Chris
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg