goto() just kind of uses the current @_ if I remeber right, correct?


Not just that. If all you wanted was to call foo with the current @_ youd write it like this:

sub bar { &foo; }

The
goto &foo;
does more. It replaces bar() by foo() in call stack. So if foo() calls caller() or croaks() it wil look like bar() was never called at all, the call stack will look like foo() was called instead.



Excellent info as usual Jenda!


In either case ... I would use the typeglob solution:

sub bar; *bar = \&foo;

That is what I will do as
1) If you say to do it I beleive it :) (Seriously I *love* Mail:Sender)
and
2) If I'm looking at the Benchmarking I did correctly glob is faster (adding the sub bar; seemed to make it even faster!!)



Benchmark: timing 100000 iterations of glob, goto, sub...
glob: 0.036653 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU) @ 10000000.00/s (n=100000)
(warning: too few iterations for a reliable count)
goto: 0.121074 wallclock secs ( 0.06 usr + 0.00 sys = 0.06 CPU) @ 1666666.67/s (n=100000)
(warning: too few iterations for a reliable count)
sub: 0.104079 wallclock secs ( 0.06 usr + 0.00 sys = 0.06 CPU) @ 1666666.67/s (n=100000)
(warning: too few iterations for a reliable count)
Rate sub goto glob
sub 1666667/s -- -0% -83%
goto 1666667/s 0% -- -83%
glob 10000000/s 500% 500% --



sub bar; is there to declare the function, so that Perl knows there is such a function. This is important if you do not use braces around parameters:

bar 1, 2, 3;

Awesome info, I really appreciate those details you bring out!


Jenda

-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to