Doesn't std.signal completely miss the point?

Cal callumenator at gmail.com
Mon Sep 5 11:57:06 PDT 2011


== Quote from Nick Treleaven (nospam at example.com)'s article
> On 04/09/2011 22:27, Andrej Mitrovic wrote:
> > From what I can tell std.signal is designed around the idea that an
> > entire class acts as a signal emitter, without the ability to write
> > multiple signals within one class and making arbitrary connections
> > between signals and slots.
> I for one was surprised when I looked at it a while ago and found it
> doesn't seem to support multiple signals per class. I'm no expert but
> I'm used to GTK+ named signals and expected something comparable.

You can have multiple signals per class by naming the mixins:

class Send
{
  void fire()
  {
    sigA.emit("A", 1);
    sigB.emit("B", 2);
  }

  mixin Signal!(string, int) sigA;
  mixin Signal!(string, int) sigB;
}

class Watch
{
   void watchA(string, int) { /// Do stuff }
   void watchB(string, int) { /// Do stuff }
}

Send s = new Send;
Watch w = new Watch;

s.sigA.connect(&w.watchA);
s.sigB.connect(&w.watchB);

s.fire();

Unless I am misunderstanding this thread?

Cheers,
Cal


More information about the Digitalmars-d-learn mailing list