www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Closures in C and Objective-C

It appears someone at Apple is adding closures to C and Objective-C.

The approach to referencing variables is different from the D and C++0x 
way: the storage class of the variable tells the compiler what to do 
with it when referenced in a closure (copy or reference) and there are 
functions to increment/decrement the reference count of the 
heap-allocated variables, allowing full closures to be returned.

<http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-August/002670.html>

I thought it might be interesting to compare this approach with the 
(somewhat contested) one in D2. For one thing, it allows much finer 
control over what and when variables are heap-allocated for the closure

-- 
Michel Fortin
michel.fortin michelf.com
http://michelf.com/
Aug 28 2008