[cfe-dev] clang++ and Lambda expressions

Douglas Gregor dgregor at apple.com
Sun Sep 12 16:32:24 PDT 2010


On Sep 12, 2010, at 3:25 AM, Nicola Gigante wrote:
> 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



More information about the cfe-dev mailing list