top | item 1595803

C++0x (upcoming C++ standard, includes lambda functions)

19 points| jacquesm | 15 years ago |en.wikipedia.org | reply

25 comments

order
[+] chc|15 years ago|reply
So the lambda functions are implemented in a way that only really works with templates and you have to explicitly pass scope? I don't really write C++ "natively," but this seems awkward to me, particularly vis-a-vis Apple's implementation of blocks in C. Does it look better to anyone who has a better handle on the feel of idiomatic C++?
[+] bff|15 years ago|reply
I've been using them for a while now (gcc has support) and they're not awkward. The ability to specify scope is actually rather nice and most of the time you'll either leave the scope empty with [] or pass everything in by value [=] or reference [&]. The return type of the lambda function is also usually detectable by the compiler so you only need to specify it rarely.
[+] plorkyeran|15 years ago|reply
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.

[+] aidenn0|15 years ago|reply
There's no such thing as idiomatic C++. The language is so huge and complex that all successful teams I've worked with that use it have selected a subset to use as part of their coding standard. In each case those subsets were different
[+] faragon|15 years ago|reply
C++ it's getting ridiculous, just like strange mix becoming a Tower of Babel.

P.S. I've working with C++ for more than 10 years.

[+] bff|15 years ago|reply
I thought the same thing when I starting working with the new standard, but I've really grown to enjoy a lot of the new features, specifically the new pointer types, rvalue references, initializer lists, variadic templates, and better support for functional programming via binds and lambdas. C++0x really does fix a lot of things that were broken on awkward previously, while also expanding support for memory and speed constrained systems via things like std::array. For me, this stuff breaths new life into the language.
[+] jey|15 years ago|reply
No, C++ is already ridiculous; it's just getting easier to deal with the existing ridiculousness.
[+] exit|15 years ago|reply
does it eliminate header files D: ?
[+] jonhohle|15 years ago|reply
I may be in the minority, but I like header files. Interface => Implementation, enforced at the file level. Add Obj-C's #import macro and they even look reasonable!
[+] lanstein|15 years ago|reply
errr haven't we missed the boat on 0x? My calendar says 2010.
[+] jacquesm|15 years ago|reply
http://en.wikipedia.org/wiki/C1X is the new 'C' draft standard, I think that the C++ guys figured they'd be ready a bit earlier than this. They might name it C++09 to save face.
[+] ori_b|15 years ago|reply
"it's in hex"