good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: When every microsecond counts: Parsing subroutine parametersby adamk (Chaplain) |
on May 19, 2008 at 04:42 UTC ( [id://687281]=note: print w/replies, xml ) | Need Help?? |
I think there might be a small mistake in one of your examples. The entire point of doing "my %args = @_" is that you then don't HAVE to extract them to their own variables. Granted, you pay incrementally per invocation of $args{...} but you don't pay for the ones you don't use. And if you only use a param once, it's cheaper than allocating it to a variable. So the slice and allocation you have there is probably superfluous Named params is also a good way to support subclassing, because you don't have to co-ordinate with child classes. You just $self->SUPER::method(@_) or $self->SUPER::method(%args); I'll also note that, for a number of position params two or smaller, it's faster to have two separate "my $var = shift;" calls than one "my ($var, $var) = @_;" call.
In Section
Meditations
|
|