signal slots (new, fixed version)

Kristian kjkilpi at gmail.com
Wed Nov 1 02:07:33 PST 2006


On Tue, 31 Oct 2006 05:41:52 +0200, Lutger <lutger.blijdestijn at gmail.com>  
wrote:
> Bill Baxter wrote:
[snip]
>> Is there no way the Signals can be initialized automatically?  It's  
>> pretty ugly to have to do a new Signal in my constructor for every  
>> signal I want to declare.  Actually I was getting crashes for the first  
>> little while before I realized I had to do that.
>>  --bb
>
> I would like that too, but I don't see an acceptable way to do it. A  
> signal needs to do some things in the destructor such as notifying  
> connected slots it does not exist anymore and freeing memory allocated  
> on the C heap. Implementing a signal as a struct instead would require  
> to call a deinit() function or something like that which I think is  
> worse.

If only there were ctors & dtors for structures...

Or if there were 'local object members' for classes, just like in C++. For  
example:

     class Foo {
         Bar m_obj;  //automatically constructed & destroyed with 'Foo'
     };



More information about the Digitalmars-d-announce mailing list