views:

802

answers:

6

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?

+65  A: 

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.

Mehrdad Afshari
+7  A: 

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.

Hank Gay
"args is a parameter". Would you agree with `args` here as a naming choice?
Liam
@Liam I probably wouldn't have chosen it, but that's the convention, so I stick by it to avoid confusion.
Hank Gay
+3  A: 

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...

CJM
+7  A: 

Parameter is variable in the declaration of function.

Argument is the actual value of this variable that gets passed to function.

Rinat Abdullin
+1  A: 

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?

ya23
A: 

There is nice section in parameter Wikipedia article about this subject.

Grzegorz Gierlik