3 ms·
The C++0x feature you're referring to is for lamdas (anonymous functions). It might be possible to use another syntax, but it would make parsing (even more of)
by scott_s 17y ago
The C++0x feature you're referring to is for lamdas (anonymous functions). It might be possible to use another syntax, but it would make parsing (even more of) a nightmare because one can use "&" or "value" inside the square brackets to indicate if values should be pass by-value or by-reference.
In practical terms, I doubt the C++ committee would change the already delayed C++0x standard to accommodate a feature which may (but probably won't) make it into C.
- pohl 17y agoInteresting, thank you. FWIW, it looks like the concept of a block is also an anonymous function, although it looks as if they only allow passing into them by value, not by reference. The developer documentation at Apple indicates that they also support these within C++, and has a small section on how they behave within it. So, at least, they went the extra mile and worked out the C++ parsing issues. http://developer.apple.com/mac/articles/cocoa/introblocksgcd.html http://developer.apple.com/mac/articles/cocoa/introblocksgcd...
- pohl 17y agoI just encountered an interesting and relevant quotation from Chis Lattner: "To head off the obvious question: this syntax and implementation has nothing to do with C++ lambdas. Blocks are designed to work well with C and Objective-C, and unfortunately C++ lambdas really require a language with templates to be very useful. The syntax of blocks and C++ lambdas are completely different, so we expect to eventually support both in the same compiler." http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-August/002670.html http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-August/00267...