david wrote:

Jupiterhost.Net wrote:


Hello list,

I was looking into the best way (and for what reasons) you'd create an
"alais" function.

For example:

If you want foo() and bar() to be able to be used interchangeably would
 it be best to do:

 sub foo { return "Howdy $_[0]"; }
 sub bar { return foo(@_); }

or do a typeglob:

 sub foo { return "Howdy $_[0]"; }
 *bar = \&foo;



for these simple examples, it doesn't matter much and i would go with the first method. functionality wise, they are pretty much the same but there are differences that you might want to observe when your foo function gets more complicated. for example, the first method has an extra function call which means it's a tiny bit slower and more importantly, the stock frame will be different and caller return different trace for this purpose so you might want to consider 'goto &foo' instead. if none of those matters to

So that woudl be: sub foo { return "Howdy $_[0]"; } sub bar { goto &foo; } ?? goto() just kind of uses the current @_ if I remeber right, correct?

you, i would just use the first method.

Thanks David I appreciate the input! I'll have to perldoc -f goto since I'm not realy familiar with it and its own issues :)


Also a bit of benchmarking may also be in order now that I have a 3rd way! and more to think about contect wise.

Thanks again!

Lee.M - JupiterHost.Net


david

-- 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