
Parameter or Argument? - nebucnaut
https://www.coati.io/blog/parameter_or_argument/
======
jdeisenberg
Using the terms in a consistent manner can avoid confusion. I tell beginning
programming students that a Parameter is like a "Placeholder," and the
Argument is the "Actual" value that fills it in, emphasizing the first letters
of each.

------
dahart
It's nice to know this distinction when you're working with other people who
expect this distinction to be followed.

Personally, I prefer the softer explanation in Wikipedia that begins, "The
terms parameter and argument are sometimes used interchangeably, and the
context is used to distinguish the meaning."

[https://en.m.wikipedia.org/wiki/Parameter_(computer_programm...](https://en.m.wikipedia.org/wiki/Parameter_\(computer_programming\)#Parameters_and_arguments)

------
more_original
One also finds the terms "formal parameter" (for what is called a "parameter"
in the article) and "actual parameter" (for what is called the "argument" in
the article).

[https://en.wikipedia.org/wiki/Parameter_(computer_programmin...](https://en.wikipedia.org/wiki/Parameter_\(computer_programming\)#Parameters_and_arguments)

------
mistermann
Could someone offer a good explanation as to why it matters in this specific
case? I can't think of any way in which a lack of knowledge of the "correct"
term could lead to something being done incorrectly.

~~~
tempodox
It always matters. The difference between argument and parameter is the
difference between concrete and abstract, or the difference between contents
and container. Would you ask whether those are relevant distinctions?

~~~
dwaltrip
Most things rarely matter always. The purpose of words is generally to convey
an idea to someone else. Humans are very effective at filling gaps or patching
over mistakes in the communications they receive. There are certain key
aspects that determine the meaning of a sentence, and one can get pretty far
by getting those parts close enough. I would param that the distinction
between "argument vs parameter" is hardly ever a key aspect in a specific
communication. The terms you mentioned are more important, so I don't the
analogy quite holds up.

If the speaker used argument or parameter incorrectly, the context would make
the intention very clear. Most listeners would make the correct mental
association without even thinking about it.

------
collyw
Does it really matter? This is the sort of thing that I would expect to come
up in some pedants interview question - it has very little with being able to
use the features effectively.

~~~
JoeAltmaier
Speaking of pedants, recent interview one guy (their 'senior scientist') spent
the whole hour tossing pedantic nits at me. What about RESTful interfaces? Are
they an API or not? Ha! They're not 'procedural'! Guess what this tiny
recursive algorithm's parameters are for? I don't know, whatever you use them
for. I would never use a recursive algorithm in embedded work (suicide). Ha!
Ha! Its the identity value over the virtual function! Ooookay. Good for you.
I'd convert it to tail recursion, then a simple iteration, and never need that
value.

Needless to say I didn't connect.

~~~
ilostmykeys
I feel your pain man. They're a lot of insecure posers out there who would
like to show you that they know more than you do. And often fail miserably at
proving their point.

------
sinatra
One easy way to remember which is which: Recall the term "command line
arguments." That will remind you that arguments are what's passed to the
function. So, parameters are what's declared/defined in the function.

------
dzdt
Is there pretty universal agreement on this? I've been around a while but
still have the "meh, the words are interchangeable" view.

~~~
tempodox
For a field that has so many elements of an exact science, I find it quite
astonishing that so many people have such a lax attitude towards fundamental
terms. But maybe that's just me.

~~~
SilasX
That would only be true for distinctions _that make a technical difference_.

There are also distinctions that _only exist_ for someone to flout[1] their
superior knowledge of the technical terms. That is a _social status_ issue,
not a matter of precision.

Best example of that case would be collective nouns: "oh gosh, you're supposed
to say a "crash" of rhinos; you can't just say a "herd" or "bunch"! ~adjusts
monocle~

Best example of "precision matters and can cause confusion" would be
"literally" or "biweekly". It causes confusion when people can't rely on
X-weekly meaning "X per week" or "every X weeks". You would be majestically
justified in prodding people to stick to the same convention to avoid
confusion.

But there any scenarios where "signature vs invocation" actually matters to
the point that you would do the wrong thing as a result of someone ignorantly
flipping the terms? The only thing I can think of would be if someone said,
with no other context, "change the parameters to fix the bug".

[1] I know, it's "flaunt", not "flout". That's the point: they don't compete
for the same semantic use cases, so they don't cause confusion.

------
flipp3r
"A Parameter is a variable in the signature of a function declaration or
definition:"

int main (int argc, char __argv)

public static void main(String[] args)

static void Main(string[] args)

sys.argv

Wait a minute...

~~~
TheCoelacanth
Those parameters hold information about the arguments that were passed in.
They don't hold information about what parameters were declared. To
programmatically get information about the parameters you would use reflection
or something like that.

------
ajarmst
This, like basically all terminology/jargon distinctions, will be community-
specific. This particular distinction is idiomatic primarily in the C family
(C, C++, Java, ad n.), primarily inheriting from the declaration/definition
distinction in the ancestral language. But jargon has dialects---some people
will have seen declaration/definition above and now be itching to correct me
with 'prototype/implementation'. In other development communities (say,
lispers), the terms may be different, the distinction may not exist or a
different one might take priority (like, say, car/cdr). As others have said,
what matters is clarity of communication, and part of that is always learning
the idiom and norms of your community. Note: in many cases there might be a
published standard (eg. K&R C, or Academie Francais French), which can inform
usage, but not necessarily prescribe it.

------
zeveb
Then there's Common Lisp, where a variable is assigned only the first time
it's defined, while a parameter is assigned every time its definition form is
evaluated:
[http://clhs.lisp.se/Body/m_defpar.htm](http://clhs.lisp.se/Body/m_defpar.htm).

~~~
junke
The meaning of parameters and arguments in the context of functions, which is
what this post is about, are defined as usual[1]:

> argument n. 1. (of a function) an object which is offered as data to the
> function when it is called.

> parameter n. 1. (of a function) a variable in the definition of a function
> which takes on the value of a corresponding argument (or of a list of
> corresponding arguments) to that function when it is called, or which in
> some cases is given a default value because there is no corresponding
> argument.

What you describe are the two possible ways of defining special variables,
which are more like _program parameters_.

[1]
[http://www.lispworks.com/documentation/HyperSpec/Body/26_glo...](http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_p.htm#parameter),
[http://www.lispworks.com/documentation/HyperSpec/Body/26_glo...](http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_a.htm#argument)

------
Bromskloss
I have never heard about the distinction anywhere in mathematics. Is this
specific to programming?

~~~
tempodox
I think so. Mathematicians talk about “arguments”, but I've never seen
“parameter” used. There are more differences in that specific area:
Mathematicians apply functions to their arguments. Only a programmer would
attempt to “call” a function. That's actually a remnant from “calling a
subroutine”, what we did in assembler, even before functions were a thing in
programming.

------
makecheck
I’ve also seen and used terms like “option” for command-line values, or “bare
argument” for values that are not tied to anything in particular. And in code,
if the documentation uses hooks like "@param" then people will naturally think
of those as parameters. You can also refer to individual fields of a data
structure as “parameters” even if they are passed to a function as one value
(and I have never seen people refer to fields as “arguments” in that
situation).

In the end, I don’t think any term is used consistently enough. People will
use whichever words they want, and you have to treat them all as potentially
referring to the same thing.

------
tempodox
I like to phrase it like this: “A parameter is a local variable that's
initialized by passing an argument”. That works for functions and C++
templates. It also works in languages like ML, where you can initialize
multiple parameters from a single argument (via pattern matching).

Consequently, speaking of “passing a parameter” is dead wrong most of the
time, except maybe when you're writing a function that “defines” other
functions, where a parameter of the function to be defined is an argument of
the definer function. But I will stop here before it gets complicated.

------
js8
Does that really correspond to usage in mathematics? I think that can be where
the confusion comes from.

Let's say: "Here we define a function f(x,y) of two arguments x and y.."

------
dandare
Wait, don't we have an _arguments_ object in JavaScript that ["is an Array-
like object corresponding to the arguments passed to a
function."]([https://developer.mozilla.org/en/docs/Web/JavaScript/Referen...](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/arguments))

~~~
TheCoelacanth
That's accurately named, though. It's values are the arguments that were
passed to the function. A hypothetical parameters object would presumably tell
you what parameters the function was declared with, e.g.

    
    
        function foo(a, b, c) {
          return parameters;
        }
    

would return ['a', 'b', 'c']

~~~
dandare
Now I understand!!! Thanks :)

------
aethos
While this is true, be aware that parameter and argument are commonly used
interchangeably.

------
uitgewis
It takes an argument and you pass it a parameter.

