7

Hopefully the topic is not too confusing, I am curious though as lately I have seen more and more use of the word parameter to denote a function's passed in values, whereas during my studies I feel as if argument was used almost exclusively.

Is parameter more appropriate as argument is more specific to a programs arguments specific at runtime whereas when a function is called, the values passed to it are parameters to the function itself?

From a curious programmer.

4 Answers 4

10

See this article in wikipedia with a good explanation. The difference is that parameters appear in method/function definitions, while arguments are concrete values you pass to a method/function.

1
  • 1
    Thanks, answers my question and actually does make sense. A function has parameters, a function is called with arguments.
    – Chris
    Nov 16, 2010 at 19:01
7

Given a function defined like:

int f(int y) { /* ... */ }

and a call like:

int a = 3;
f(a);

y is the parameter (aka "formal parameter"), and a is the argument.

6

I found this definition very simple to explain:

  • a parameter is a "hole" in your function definition
  • an argument is what the client uses to fill that "hole"
0

In college, I was taught that the correct term is "argument". I think either are appropriate and both definitions are obvious to most developers, but, from a technical standpoint, I generally stick with "argument".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.