On Monday, 15 April 2013 at 12:07:19 UTC, Denis Shelomovskij wrote:
15.04.2013 13:07, Robert пишет:
2. Make regular D objects on closures [4] to be able to know when delegate's outer scope is destroyed (this will auto-fix both [5] and
[2], see Comment 2 of [2] for code example)

I still don't understand what that buys us. Having a closure being an object would make it possible to use a weak reference, but why would you want that? The signal would be the only one to hold a reference to the lamdas context, if this reference was a weak one, then the memory would be claimed immediately. This is why std.signals2 holds a strong ref to the delegate context of a wrapping closure and a weak ref to the target
object.

With your `std.signals2` one can't e.g. forward delegate connection like this:
---
/// Usage: don't pass struct pointer delegates as `del`.
void f(void delegate() del)
{
    obj.event.connect(del);
}
---
as you require explicit passing an object owning a delegate.

But it is completely unnecessary as delegate do know where it was born from and the fact this information isn't tracked when a closure is created is a language design issue. One of those fixing which is easy, will not break any code and will improve things a lot.

Even with that explanation, I still don't see the problem.

Reply via email to