Default value of arguments

When defining a function the default value of an input argument can be specified using the assignment operator =. When calling a function, the symbol * should be given to each argument for which default argument value is intended. For example:
>> f = function (x = 3, y = 5, z = 7) -> w
       // define function w = f(x,y,z), with
       // default argument values 3, 5, 7
         ...
   end
>> f(*, 10, *)   // equivalent to f(3, 10, 7)
Here the default values of the 1st and 3rd arguments are passed to the function.

Function calls don't have to match the signature of the function definition exactly. To be specific, there are the following situations.

Another fact is that every function argument has a default default value. The default default value of an input argument is null (which is the same as the empty matrix []). Of course, unless the function definition code does something to handle default default value, using it directly will usually cause an error.

oz 2009-12-22