clang++ and Lambda expressions

Hello.

What are the plans to support the lambda expression c++0x feature in clang? It's notable that VC2010 adds
production-ready support for them.
I'm trying to understand what would be needed to implement the new feature. From my understanding, it will be
simpler than the implementation of the blocks extension, since a lambda expression simply declares and instantiate
a kind of functor class (have I understood correctly?)

If I'm correct, then the only two components affected by this new feature are AST and Sema, and no changes are
required to the lexer and the code generation stuff, right?

So what actually needs to be done to support lambda expressions?

Bye,
Nicola

Lambdas use a slightly modified form of the new function declaration syntax.

There is also the issue of capturing lambdas in a variable. Since the type of a lambda is compiler generated (I believe) it will be most common to use the auto typename, which I have a patch for (I just haven't gotten around to writing the tests).

After auto, the function declaration syntax was next on my list, but I rarely have the time to work on it all.

What are the plans to support the lambda expression c++0x feature in clang?

There are no plans per se, and I don't recall anyone else having expressed an interest in implementing lambdas. Most people working on Clang are focused on improving C++98/03 support or working on more of the core C++0x features (rvalue references, variadic templates, decltype, noexcept).

It's notable that VC2010 adds
production-ready support for them.
I'm trying to understand what would be needed to implement the new feature. From my understanding, it will be
simpler than the implementation of the blocks extension, since a lambda expression simply declares and instantiate
a kind of functor class (have I understood correctly?)

Yes, it should be simpler than blocks; there's no run-time to interact with, and the capture rules are somewhat simpler.

If I'm correct, then the only two components affected by this new feature are AST and Sema, and no changes are
required to the lexer and the code generation stuff, right?

There will be a small amount of work to be done for code generation, in name mangling and possibly to cope with the conversion to a function pointer. Of course, there's also work in the parser itself.

So what actually needs to be done to support lambda expressions?

We've listed the main ingredients. It's not an easy feature to implement, but it's impact should be relatively isolated in each of the Clang components involved, and the implementation itself should be relatively straightforward.

  - Doug