Positional versus named parameter notation v16
You can use either positional or named parameter notation when passing parameters to a function or procedure.
If you specify parameters using positional notation, you must list the parameters in the order that they are declared. If you specify parameters with named notation, the order of the parameters doesn't matter.
If you specify parameters using named notation, list the name of each parameter followed by an arrow (
=>
) and the parameter value. Named notation is more verbose but makes your code easier to read and maintain.
This example uses positional and named parameter notation:
To call the procedure using positional notation, pass the following:
To call the procedure using named notation, pass the following:
If you used named notation, you don't need to rearrange a procedure’s parameter list if the parameter list changes, the parameters are reordered, or an optional parameter is added.
When an argument has a default value and the argument isn't a trailing argument, you must use named notation to call the procedure or function. This example shows a procedure with two leading default arguments:
You can omit nontrailing argument values when you call this procedure only by using named notation. When using positional notation, only trailing arguments are allowed to default. You can call this procedure with the following arguments:
You can use a combination of positional and named notation, referred to as mixed notation, to specify parameters. This example shows using mixed parameter notation:
You can call the procedure using mixed notation:
When using mixed notation, named arguments can't precede positional arguments.