On Fri, Jun 26, 2009 at 8:54 PM, Kyle Sluder<kyle.slu...@gmail.com> wrote: > Closures are notoriously hard to implement without some form of > automatic memory management. Forgetting everything announced and > unannounced about upcoming features of ObjC, we have a small version > of this issue right now, when dealing with NSBeginAlertSheet context > pointers.
Well, I think that ignoring Apple's upcoming blocks is a mistake here, because all the relevant details are now public, their implementation does not require garbage collection, and it's interesting to see how they've done it. Details on how it all works are here: http://clang.llvm.org/docs/LanguageExtensions.html#blocks The short version is this: blocks are objects which, in a non-GC app, just get retained and released as usual. When a block is copied, all of the object-pointer variables that it references get retained to keep them alive (and subsequently released when the block is destroyed). There are some obvious problems with retain cycles due to this design which will probably somewhat limit where blocks can be used, but overall it seems pretty straightforward and effective. Mike _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com