On Nov 30, 2007, at 7:38 PM, Charles Yeomans wrote:
>>> It's important to note that the delegate stores a strong ref to the
>>> instance behind your back, which can wreak havoc if you rely on
>>> things automatically cleaning up after themselves. In general I'd
>>> think delegates that held weak refs and fired exceptions when
>>> "Invoked" on a Nil object would be more useful, but I'm sure RS had
>>> their reasons for the current implementation.
>>
>> Requested:
>>
>> <http://www.realsoftware.com/feedback/viewreport.php?
>> reportid=oqccypjd>
>>
>
> I note, though, that delegates can be stored in WeakRef objects. So
> I'm not sure that such a feature request is crucial.
I thought about that. But if you don't want the delegate to get GCd,
you need a regular reference to the delegate somewhere, and then the
problem just comes back.
There *is* a workaround, but it's to use a Class Interface with a weak
reference, rather than a delegate. Which could be kind of clumsy,
particularly if you want to be able to call from somewhere to either
instance or static methods.
This makes me realize: if you could treat a delegate as an object
satisfying a matching class interface, that would be a halfway
solution, and a reasonable sort of abstraction to have, anyway.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|