> I could see something like:
>
> method operator.( $self: $function ) {
>   if( $function eq "inc" ) { ++%self.funcount{$_[2]}; }
>   else { $self.inc( $function ) }
> }
>
> That would count how many times you called each function.

Sounds a lot like aspect-oriented programming. If what you want is
overriding functions to do other stuff before, after, or both before and
after, a function, then aspects should be enough for you. Check out
Aspects on CPAN for a Perl 5 implementation, or the AspectJ stuff for the
original (at least, I think it was the first) definitive source for this
kind of stuff.

Of course, overloading and/or changing the way certain operators work
should be fair game in Perl6 along with the rest of the grammar. But I'm
just pointing out that this other solution will solve your recursiveness
problem, and is doable today, in Perl 5. It's also a much nicer interface
to this kind of programming. :)

Mike Lambert

  • -> and . Tanton Gibbs
    • Michel J Lambert

Reply via email to