I often find myself confused with how the terms 'arguments' and 'parameters' are used. They seem to be used interchangeably in the programming world.
What's the correct convention for their use?
I often find myself confused with how the terms 'arguments' and 'parameters' are used. They seem to be used interchangeably in the programming world.
What's the correct convention for their use?
Parameters are the things defined by functions as input, arguments are the things passed as parameters.
void foo(int bar) { ... }
foo(baz);
In this example, bar
is a parameter for foo
. baz
is an argument passed to foo
.
Arguments are what you have when you're invoking a subroutine. Parameters are what you are accessing inside the subroutine.
argle(foo, bar);
foo
and bar
are arguments.
public static void main(final String[] args) {
args.length;
}
args
is a parameter.
Although Wikipedia is hardly an authoritative source, it does a decent job of explaining the terms.
I guess you could say that parameters are to arguments what classes are to instances of objects...
Parameter is variable in the declaration of function.
Argument is the actual value of this variable that gets passed to function.
I've also come accross Formal Parameter as the variable defined in the function declaration and Actual Parameter as the actual values you pass. Can anyone tell whether it is correct terminology?
There is nice section in parameter Wikipedia article about this subject.