On Thursday, 23 January 2014 at 22:58:08 UTC, Martin Nowak wrote:
On 01/13/2014 10:16 PM, ilya-stromberg wrote:
It's not so good to have array of delegates because you will
have a
memory leaks. Delegate has permanent pointer to the object, so
GC will
never free it. As alternative, you can delete delegate
manually, but in
this case you can have problems with manual memory management.
So, array of delegates is possible solution, but only for VERY
simple
cases. This module solves problem with memory leaks because it
implements weak connections (based on weak reference). It's
easy to use,
but VERY difficult to implement.
But weak references should be implemented on GC/druntime level.
Yes, I know. They can be useful for many other purposes. I just
provide example when `std.signal` better than `array of
delegates`.