Indeed. All we need now is bind/callcc and we'd have the ultimate frankenlanguage!
In all seriousness, I'm really happy to see "lower-level" languages adopting these features. Makes so many problems that much easier to solve! I wonder about the implementation details, though - I wouldn't mind reading an analysis of closures in C++ vs. the VM languages.
The implementation is compiler dependant. Nevertheless, it would appear that the normal implementation is to create something which looks like a normal object with pointers back to the state it closes around. In theory it should be fast and light. The problem (as always with C++) is ensuring that the things to which the pointers point does not go away. Smart pointers help - but they are slow...
I think the most common use case for blocks in C++ are functional-ish STL algorithms, unlike C blocks, which were built for async operations. In that use case, they absolutely shine - since they don't outlive their parent scope, no memory management is necessary, they can be inlined and ideally add no overhead. I think this easily outweighs the cases where you need slow shared pointers.
C++ blocks are pretty straightforward - they are syntactic sugar for functor structs, memory management is still up to you.
I find Apple's C blocks a much more interesting design with some tricky trade-offs. And to top it off, the LLVM compiler treats C++ objects referenced in C blocks correctly, and you can pass C blocks to the STL for all purposes I can think of.
> I'm really happy to see "lower-level" languages adopting these features. Makes so many problems that much easier to solve!
Wouldn't it be much easier to use a high level language like Scheme which has these nice features built in already, and let C/C++ just do the lower level stuff they were created for?
In my (admittedly small) experience, avoiding the context switch between languages is generally a good thing. That said, there isn't a silver bullet but this puts C++ one step closer to being the ultimate bridge language and that's definitely a good thing.