Re: GC pros and cons
Re: GC pros and cons
- Subject: Re: GC pros and cons
- From: Michael Ash <email@hidden>
- Date: Fri, 26 Jun 2009 22:02:14 -0400
On Fri, Jun 26, 2009 at 8:54 PM, Kyle Sluder<email@hidden> 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 (email@hidden)
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:
This email sent to email@hidden