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

14.12.2 Optional Arguments

Optional function arguments are specified like:

fun atoi = (string s, int b = 10) long: { … }

Which means that if the base argument is not specified when passed to atoi then it is initialized to 10.

Optional arguments should not appear before any non-optional argument in function declarations. The following is not valid Poke:

fun foo = (int i = 10, int j) int: { return i + j; }

Note that arguments declared before an optional argument can be used in its initialization expression. This is valid Poke:

fun foo = (int n, int[n] array = init_array (n)) void: { … }