std.signal woes :/
Damian
damianday at hotmail.co.uk
Sun Feb 24 09:30:13 PST 2013
On Saturday, 23 February 2013 at 23:39:19 UTC, cal wrote:
> On Saturday, 23 February 2013 at 17:01:48 UTC, Damian wrote:
>> Ok signals work fine, until I use them in a descendant class.
>>
>> Snippet:
>> -----------------
>> import std.signals;
>>
>> class ClassA
>> {
>> public mixin Signal!(int) addNumber1;
>> }
>>
>> class ClassB : ClassA
>> {
>> public mixin Signal!(int) addNumber2;
>> }
>>
>> Error:
>> \dmd2\src\phobos\std\signals.d(0,0): Error: function
>> main.ClassB.Signal!(int).emit cannot override final function
>> main.ClassA.Signal!(int).emit (moooo)
>>
>>
>> Is this expected behavior or a bug in my code?
>
> I think this is a known issue. Here is a workaround I've used:
>
>
> import std.signals;
>
> struct MySignal(T)
> {
> mixin Signal!T _signal;
> alias _signal this;
> }
>
> class ClassA
> {
> MySignal!int addNumber1;
> }
>
> class ClassB : ClassA
> {
> MySignal!int addNumber2;
> }
>
> void main()
> {
> auto a = new ClassA;
> auto b = new ClassB;
> a.addNumber1.emit(1);
> b.addNumber1.emit(1);
> b.addNumber2.emit(1);
> }
That solution is ok for 1 argument but for many arguments it wont
suffice.
This is issue 5028.
More information about the Digitalmars-d-learn
mailing list