[cfe-dev] blocks and lambdas

James Gregurich bayoubengal at mac.com
Fri Feb 11 18:04:21 PST 2011


thanks. I've already submitted a feature request through ADC. I'm confident that you guys can make it happen.

-James

On Feb 11, 2011, at 2:31 PM, Douglas Gregor wrote:

> 
> On Feb 10, 2011, at 4:47 PM, James Gregurich wrote:
>> I'm coming to the engineers working on a brand new C++ compiler before they have implemented much of this stuff and I'm saying....think this problem out NOW and make it nice BEFORE you have a legacy code base to worry about....integrate it and make it work well so that we can have a nice, standards-based system. 
>> 
>> I really don't understand why that is a statement that inspires objection. It seems to me that clean, tight, well-designed integration between Apple technology and standards-based technology should be a goal. I am encouraged by the fact that one of the Apple engineers is thinking about this concept and would like to try to make it work. I will be filing a feature request on ADC to officially log my desire for clean, automatic integration of lambdas with with Blocks-based APIs.
> 
> 
> In general, requests for features that involve Apple APIs and technologies should go through Apple's support channels (ADC). This list concerns the open-source Clang project, where Apple is but one of many concerned institutions.
> 
> With respect to lambdas and blocks, I too would like to see some level of interoperability. As John mentioned, an implicit conversion from a lambda object to a block pointer seems completely reasonable, and would allow one to seamlessly [*] use C++0x lambdas as arguments to APIs that take block pointers. Blocks can already be used with many APIs that accept C++0x lambdas, since a block behaves like a C++ function object so long as one handles the block copy/release externally. I doubt we'll see any low-level compatibility between the two features, e.g., C++0x lambda objects aren't likely to ever have the same layout as blocks, since C++ programmers won't want that memory cost for simple lambdas.
> 
> 
> That said, nobody has actually looked into the implementation of lambdas in Clang, and I haven't seen any indication that it is coming soon. There's not much more we can do until that happens.
> 
> 	- Doug
> 
> [*] Subject to sensible capture semantics, which is complicated by the fact that blocks and C++0x lambdas capture referenced variables in very different ways. This is something that needs to be carefully designed offline.
> 




More information about the cfe-dev mailing list