> I understand the problem you're describing (and yes, I've had a couple of 
> memory leaks resulting from it) but I don't understand how you think it's 
> breaking encapsulation.

The encapsulation is broken by the fact that you can't place whatever code you 
need in the callback block and have to always remember about internal 
implementation of blocks, and its possible implications and side effects, even 
for the simplest cases. It's definitely not something you'd want to focus on, 
given that blocks were called to make life easier, not harder. Implicit 
side-effects are always harder to track and debug. 


> 
> In my code, most of the places I use a block as an onXXX property value it's 
> going to be called exactly once. What I do then is, in the caller, set the 
> corresponding _onXXX ivar to nil after calling through it, to break cycles.
> 

I made it clear in the subject that I was talking about callbacks. There are 
perhaps a number of cases (iterators, threading) where blocks are not copied 
and seem to be perfectly fine. 
_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to