On 4 February 2014 14:27, Manu <turkey...@gmail.com> wrote:

> On 4 February 2014 14:19, Michel Fortin <michel.for...@michelf.ca> wrote:
>
>> On 2014-02-04 03:45:33 +0000, Manu <turkey...@gmail.com> said:
>>
>>  The majority of trivial allocations don't produce cycles; closures,
>>> strings, temporary arrays and working sets.
>>>
>>
>> Oh, no. Beware of closures. That's a frequent problem in Objective-C ARC,
>> even for those who understand ARC well. You have to be very careful of
>> closures creating cycles if you use them as callbacks. For instance, you
>> have a view that has a pointer to the model and sets a callback for the
>> model to call when something change to update the view; that's a cycle and
>> you need to use a weak ref to the view within the closure. Pretty common
>> pattern.
>
>
> Ah right. Interesting.
> It sounds like this could be addressed easily though by the API that
> manages the 'event' handler. If you use a raw delegate, maybe it's a
> problem, but it sounds like an event-programming construct, and that
> usually requires an event class that can handle multiple subscribers, as
> soon as that exists, it's easy to hide the weak reference behind the event
> api...
>

I can say that all the closures that I've observed in my D apps so far have
been entirely trivial.

Reply via email to