>   Hi guys, i was just wondering if some notification mechanism (
> signal/slot alike ) was planned in perl 6, like they already are in
> glib and qt ?

  class Signal {
    has @.dest;

    method emit($code)  { $code($_) for @.dest }
    method attach($obj) { push @.dest: $obj }    
  }

  class Foo {
    has Signal $.valueChanged is public;
    has $.value is public;
    
    method value($newval) {    # Overriding default accessor
      $.value = $newval;
      emit $.valueChanged: { .($newval) };
      $.value
    }
  }

  my Foo $a, $b;
  $a.valueChanged.attach($b, { $b.value($_) });


Or something like that.  Already supported :)

It's neat how powerful the closure is.  I can't wait until I
understand continuations!

>   And no, i'm not planning on doing it myself :-/

Planning on changing your plans now?

Luke

Reply via email to