[cfe-dev] [GSoC] "C++0x Lambda functions implementation" proposal

Jonathan Sauer jonathan.sauer at gmx.de
Wed Mar 30 11:59:36 PDT 2011


Hello,

>>> [...]
>>> This project will implement lambda functions in Clang, including other needed C++0x features.
>>> In particular, this will imply the implementation of at least the new "lately-specified return type" syntax.
>> 
>> According to the overview <http://clang.llvm.org/cxx_status.html>, this feature has not been implemented
>> (or even started) yet. I am currently too tired to be able to parse 8.3.5p2 reliably, but the following
>> works (well, compiles) in clang revision 128404:
>> [...]
> 
> Oh, ok. The status page should be updated then. Anybody knows which revision introduced this?
> Other thought on the proposal in general?

One one hand, it seems simple: Just transform a lambda into a local struct, turn captured variables into
attributes and initialize them in the local struct's constructor. Finally create an anonymous instance of
this struct and use it in place of the lambda (a bit like it is described here:
<http://stackoverflow.com/questions/3218821/c0x-lambda-overhead>).

(just ignore interaction with ObjC blocks. They are too different from each other)

On the other hand, clang is a really complex system, and C++ is a grotesquely complicated language, so
the integration of lambdas into the compiler will be a lot more difficult than the simple transformation
I outlined above. Therefore I wonder if you will have enough time to complete your implementation,
especially if you're not proficient in clang. OTOH, IMO even a partial, but working and well-documented
implementation still is better than none.

Finally, when I read your first announcement on this list, I was very excited, because although I realized
that other C++0x features such as rvalue references were far more needed than lambdas (they are, after all,
"just" syntactic sugar), they are still useful (but why, oh why couldn't they be polymorphic?).

So I say: Go for it! :-)


Jonathan





More information about the cfe-dev mailing list