Is there any plans to make working signals in D?

Denis Shelomovskij verylonglogin.reg at gmail.com
Tue Apr 16 23:15:42 PDT 2013


16.04.2013 13:17, deadalnix пишет:
> On Tuesday, 16 April 2013 at 07:55:51 UTC, Denis Shelomovskij wrote:
>> Sorry, I really don't understand what you don't understand.
>>
>> Let's consider example from Issue 9603 Comment 2 [1]. Do you think
>> such code must not work?
>>
>> Also you can look through Issue 9601 discussion.
>>
>> [1] http://d.puremagic.com/issues/show_bug.cgi?id=9603#c2
>> [2] http://d.puremagic.com/issues/show_bug.cgi?id=9601
>
> The code in 9603 is completely broken. It should compile and run, but
> what it does is undefined as o is finalized when delegates have
> reference to it.
>
> I don't see how changing delegate into object would change anything, as
> the code would be broken in the same way for the same reason.

Current behaviour when delegates stays alive when its outer scope is 
destroyed is just a bad language design.

Let's assume there is a "magic" way to make code in Issue 9603 work. Do 
you think this is usable?

So, the "magic": I propose to make an object on closure creation (i.e. 
just prepend allocated closure with few hidden fields) and add "finalize 
the closure" to outer scope dispose event. And I already described it in 
Issue 9601 and its comments. What is non-obvious here?

Note: This can work just the same way if there is no GC-allocated closure.

-- 
Денис В. Шеломовский
Denis V. Shelomovskij


More information about the Digitalmars-d mailing list