Advantages of dynamically typed languages that can add function (subroutine) arguments
The number of arguments of a function (subroutine) of a dynamic language such as Perl is dynamic, and you can add arguments even after implementing the subroutine.
This means that if the subroutine definition is modified, the original function call does not need to be modified.
# First one argument sub func { my ($arg) = @_; } #Call func (1);
Now suppose you need an option for this subroutine. In this case, there is no need to modify the original call location.
# Add option sub func { my ($arg, $opt) = @_; $opt || = {}; } #The original call doesn't have to be modified func (1); #Call with options func (1, {foo => 4});
What kind of method can be considered to realize it in a statically type language?
For example, you can use the Java or C ++ overload feature to define a new method with the same name, but with a different number of arguments, without breaking the original call.
However, in this case, since the method is newly defined, the number of method definitions increases.
Note that we did not increase the arguments of the original method itself.