• Advertisement
Sign in to follow this  

Lambda functions in C++?

This topic is 4741 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

On the comp.lang.c++.moderated newsgroup there's an ongoing discussion about adding lambda functions to C++. Here's the proposal: http://www.msobczak.com/prog/articles/lambdacpp.html I really hope this happens (though its unlikely to be included in the new 0x standard). Anyone else think this would be a great addition to the language? -Alex

Share this post


Link to post
Share on other sites
Advertisement
Without adding closures as a basic data type which is managed by the language/compiler, it doesn't really offer anything new or useful. So, no.

Share this post


Link to post
Share on other sites
Quote:
Original post by Wyrframe
Without adding closures as a basic data type which is managed by the language/compiler, it doesn't really offer anything new or useful. So, no.


How come? Certainly full closures would be nice, but even without them, lambdas would definitely come in handy in many situations. Just check the proposal's examples. Besides, they would be completely trivial to implement, compared to full closures which pretty much require a language-level support for garbage collection.

Some form of closure support might still be feasible, for example, you could forbid returning functions that touch their enclosing function's local variables, just like it is currently undefined behaviour to return a reference to a local.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement