in reply to Re^2: What's the better Perl style? Define parameters or not?
in thread What's the better Perl style? Define parameters or not?
A sub is a method right, so I assumed its called like one.
Prototypes change how the parser interprets the syntax of a call when Perl compiles the program. It's easy to figure out which apply() function gets called when you write:
sub apply_arguments { my ($item, @args) = @_; for my $arg (@args) { apply( $item, @args ); } }
It's much more difficult to figure out which apply() method gets called when you write:
sub apply_arguments { my ($self, @args) = @_; for my $arg (@args) { $self->apply( @args ); } }
The appropriate method may not even exist at that point in the program.
|
|---|