SIMPOL Documentation

Function Parameters

Function parameters can be named and take a default value. Actual parameters supplied when the function is called can be specified by name, and if not specified at all will take the default value. When passing parameters to a function named parameters are resolved and passed first, and then unnamed actual parameters are passed to the unused function parameters from left to right. Finally any unpassed parameters are set to their default values, or if none is specified unused parameters are set to .nul.

For example, the following program produces a result value of: x = abc, y = <y not specified>

function main()
end function x_and_y(x = 'abc')

function x_and_y(string x = '<x not specified>', string y = \
                 '<y not specified>')
end function "x = " + x + ", y=" + y

Also, the next program produces a result value of: x = xyz, y = <y not specified>, z = uvw

function main()
end function x_and_y_and_z(z = 'uvw','xyz')

function x_and_y_and_z(string x = '<x not specified>', string y =\
  '<y not specified>', string z = '<z not specified>')
end function "x = " + x + ", y=" + y + ", z= " + z

Functions, types and local variables all have names, and parameters can be named. In order to be valid a name must start with a letter and all other characters in it must be a letter, a digit or an underscore.