in reply to Re^4: When every microsecond counts: Parsing subroutine parameters
in thread When every microsecond counts: Parsing subroutine parameters
Yeah, there's a much better and cheaper way - don't name them, name the indices into @_ via constant subs, if you need names instead of numbers for sake of code clarity:
sub FOO () { 0 } sub BAR () { 1 } sub routine { my $bar = $_[BAR]; $bar += munge( $_[FOO] ); }
But it is crucial for that discussion to identify when it is beneficial to use named parameters, and why. I can think of:
All other reasons seem to be based on gusto. But then, in early perl OO, objects were mostly blessed hashrefs (tutorials and perl pods are full of them), and much unreflected use of named parameters stems from there, I guess.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: When every microsecond counts: Parsing subroutine parameters
by BrowserUk (Patriarch) on May 18, 2008 at 07:18 UTC | |
by shmem (Chancellor) on May 18, 2008 at 08:50 UTC |