Dulcimer wrote:
sub slow_fn {
  my $tick = Timer.new(60, { print "..." });
  return slow_fn_imp @_;
}

Now if I could just get the compiler to not complain about that
unused variable...


Maybe I'm being dense....
Why not just
 sub slow_fn {
   Timer.new(1, { print "." });
   return slow_fn_imp @_;
 }

The problem is that I want the timer to last for the duration of the slow_fn_imp. If I don't assign it to a variable, then it may be GCed at any time.


I've just realised, however, that I'm relying on it being destroyed on leaving the scope. I'm not sure that the GC guarentees that. I might need

  sub slow_fn {
    my $timer is last { .stop } = Timer.new(60, { print "." });
    return slow_fn_imp @_;
  }

but that's starting to get cluttered again.


Dave.




Reply via email to