[cfe-dev] blocks and lambdas

James Gregurich bayoubengal at mac.com
Thu Feb 10 16:47:03 PST 2011

yes. I am used to have to roll my own glue to make standard code with with Apple APIs. However, it would be nice if Apple's dev tools and APIs were structured to just work with the standards and not put the end user through hoops to coerce cooperation. 

A good example of such hoop-jumping was with the integration of ObjC and C++ exceptions. If the unification had been done at macOSX 10.0, then I would have been spared writing macros to try and mangle the two systems cleanly on both the the 32 bit macosx case and the opposing case.  I'd like to avoid that kind of crap. It makes my code harder to maintain and debug.

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.

On Feb 10, 2011, at 1:18 PM, Bruno Santos wrote:

> Qui, 2011-02-10 às 12:44 -0800, James Gregurich escreveu:
>> On Feb 10, 2011, at 12:35 PM, Bruno Santos wrote:
>>> The problem is the "set of captured items". If a lambda does not capture
>>> any items it can be used as a function pointer, I don't think you can do
>>> that with a block since it carries baggage with it even if you don't
>>> capture items. It would also violate one of the fundamental design
>>> philosophies behind C++: "you don't pay for what you don't use".
>> fair enough. but, you can still provide for automatic conversion in cases where one wants to feed a lambda to libdispatch or some some cocoa/foundation class. As I said earlier in this thread...if you can make that happen, I'll be happy.
>> The goal that I'm lobbying for is to allow 3rd party mac developers to keep as much of their code in standard syntax and built upon standard libs as possible. Not only does it make the lives of existing mac developers easier, but it lowers the barrier to developers from other platforms to come to the mac.
> You can write a generic warper that adapts a function object (a lambda)
> to a block. This can be done in a very generic way with the powerful
> metaprograming capabilities of C++. Just have a look at Boost.Function
> and Boost.Bind.
> Once you have your warper it will be trivial to adapt a lambda to a
> block.

More information about the cfe-dev mailing list