Variadic function: Difference between revisions

Content deleted Content added
m subsection for optional args
Optargs and kwargs aren't varargs -- please see talk
Line 8:
 
In [[PHP]], [http://php.net/functions_arguments variable-length argument lists] are natively supported (without security risk) since version 4; dedicated functions (func_num_args, func_get_arg, func_get_args) allow the programmer to determine the number and values of unspecified arguments.
 
=== Optional arguments with default values ===
 
Besides the concept of a ''completely arbitrary number'' of arguments as discussed above,
the declaration of '''[[default value]]s''' for ''some'' of the ''specified arguments'' is another concept allowing to call a function with variable number of arguments.
Several [[typed language]]s implement this, and can in some cases associate the arguments to the corresponding variables in view of their type, even if they are given at [[call-time]] in an order differing from the declaration.
In languages which are not (strongly) typed (such as PHP), such [[optional argument]]s with default values cannot precede [[mandatory]] arguments without default value. (An exception are some system functions of PHP, like [http://php.net/implode the implode function], that can associate arguments given in any order to the right variables, in view of their type.)
 
== See Also ==