On Mon, Aug 27, 2001 at 06:50:35PM -0400, Ken Fox wrote:
> Michael G Schwern wrote:
> > Any time you want to implicitly pass @_, you can just as easily
> > *explicitly* pass it or use goto.
>
> I never thought of using goto actually. "goto &$method;" actually
> looks clearer than the code I'm using. (Although with re-directors
> we want to minimize cost so the 10% penalty should be eliminated.)
Larry Wall has a quote about goto somewhere...
It would be possible to optimize some forms of goto, but I haven't
bothered.
-- Larry Wall in <[EMAIL PROTECTED]>
but I think he was refering to goto LABEL.
Anyhow, with a redirector it's more important for caller() to be
untouched than a little microptmization, so goto is the way to go.
If you *really* wanted to write an optimized redirector, you'd
have the redirector eliminate itself.
sub foo {
my $method = $_[0]->{"_foo"} || $_[0]->can("_foo");
{
no warnings 'redefine';
*foo = $method;
}
goto &$method;
}
in the first call to foo(), the redirector will replace itself with
the real method. Thereafter, it's a normal method call. That's the
real savings.
--
Michael G. Schwern <[EMAIL PROTECTED]> http://www.pobox.com/~schwern/
Perl6 Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One
Death follows me like a wee followey thing.
-- Quakeman