Next: , Previous: , Up: Statements   [Contents][Index]

7.14 Extended Parameter Lists

If a subroutine or function was defined by the user with an extended parameter list (Subroutine Definition, Function Definition) and if it is called with more arguments than there are explicit parameters in the parameter list, then the last named parameter is changed into a cplist variable and the excess arguments are stored in it. A cplist variable is a compact list of pointers to variables, and (currently) occurs only in the context of an extended parameter list to a user-defined subroutine or function.

 SUBR FOO,x,...

The above example shows the simplest extended parameter list. If this subroutine is called through FOO,y then, inside the subroutine, x will receive whatever the value of y happens to be. This is just like what would happen if the subroutine were defined without the ....

However, if the subroutine is called through FOO, x, y, then there are more arguments than explicit parameters, and then the extended parameter treatment will be used: inside the subroutine, x will be a compact pointer list, equal to {&x, &y}. In that case, you can assign the value 5 to y inside the subroutine by including a statement like x(1) = 5.