Why we want subroutine signatures?
As a first starting point, why do we want a subroutine signature?
What is missing in Perl?
JavaScript Function Definition
At first, see JavaScript code. foo function definition.
function foo (args1, args2) { }
Ruby Function Definition
Next, see Ruby code of foo function definition.
def foo (args1, args2) end
Python Function Definition
Next, see Python code of foo function definition.
def foo (args1, args2)
PHP Function Definition
Next, see PHP code of foo function definition.
function foo ($args1, $args2) { }
Perl Function Definition
Last, see Perl code of foo function definition.
sub foo { my ($args1, $args2) = @_; }
Why Perl don't write the other languages?
Argument definition is very generally expression
Argument definition is very generally expression in other all of modern programming languages.
People say
"What is @_?"
"Perl have many symbols."
"Perl is a old and dirty language"
We need subroutine signatures to make Perl argument definitions fit into a very general expression.
This is most biggest reason.
Subroutine signatures remove one of the criticisms "Perl is unreadable".