TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Parameter or Argument?

55 pointsby nebucnautalmost 9 years ago

17 comments

jdeisenbergalmost 9 years ago
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.
dahartalmost 9 years ago
It&#x27;s nice to know this distinction when you&#x27;re working with other people who expect this distinction to be followed.<p>Personally, I prefer the softer explanation in Wikipedia that begins, &quot;The terms parameter and argument are sometimes used interchangeably, and the context is used to distinguish the meaning.&quot;<p><a href="https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Parameter_(computer_programming)#Parameters_and_arguments" rel="nofollow">https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Parameter_(computer_programm...</a>
more_originalalmost 9 years ago
One also finds the terms &quot;formal parameter&quot; (for what is called a &quot;parameter&quot; in the article) and &quot;actual parameter&quot; (for what is called the &quot;argument&quot; in the article).<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Parameter_(computer_programming)#Parameters_and_arguments" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Parameter_(computer_programmin...</a>
mistermannalmost 9 years ago
Could someone offer a good explanation as to why it matters in this specific case? I can&#x27;t think of any way in which a lack of knowledge of the &quot;correct&quot; term could lead to something being done incorrectly.
评论 #12093631 未加载
评论 #12094256 未加载
collywalmost 9 years ago
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.
评论 #12093324 未加载
评论 #12093738 未加载
评论 #12093299 未加载
评论 #12093617 未加载
评论 #12093323 未加载
sinatraalmost 9 years ago
One easy way to remember which is which: Recall the term &quot;command line arguments.&quot; That will remind you that arguments are what&#x27;s passed to the function. So, parameters are what&#x27;s declared&#x2F;defined in the function.
dzdtalmost 9 years ago
Is there pretty universal agreement on this? I&#x27;ve been around a while but still have the &quot;meh, the words are interchangeable&quot; view.
评论 #12093751 未加载
评论 #12094126 未加载
flipp3ralmost 9 years ago
&quot;A Parameter is a variable in the signature of a function declaration or definition:&quot;<p>int main (int argc, char <i></i>argv)<p>public static void main(String[] args)<p>static void Main(string[] args)<p>sys.argv<p>Wait a minute...
评论 #12094170 未加载
评论 #12094248 未加载
ajarmstalmost 9 years ago
This, like basically all terminology&#x2F;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&#x2F;definition distinction in the ancestral language. But jargon has dialects---some people will have seen declaration&#x2F;definition above and now be itching to correct me with &#x27;prototype&#x2F;implementation&#x27;. 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&#x2F;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&amp;R C, or Academie Francais French), which can inform usage, but not necessarily prescribe it.
zevebalmost 9 years ago
Then there&#x27;s Common Lisp, where a variable is assigned only the first time it&#x27;s defined, while a parameter is assigned every time its definition form is evaluated: <a href="http:&#x2F;&#x2F;clhs.lisp.se&#x2F;Body&#x2F;m_defpar.htm" rel="nofollow">http:&#x2F;&#x2F;clhs.lisp.se&#x2F;Body&#x2F;m_defpar.htm</a>.
评论 #12094514 未加载
Bromsklossalmost 9 years ago
I have never heard about the distinction anywhere in mathematics. Is this specific to programming?
评论 #12094194 未加载
makecheckalmost 9 years ago
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 &quot;@param&quot; 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).<p>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.
tempodoxalmost 9 years ago
I like to phrase it like this: “A parameter is a local variable that&#x27;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).<p>Consequently, speaking of “passing a parameter” is dead wrong most of the time, except maybe when you&#x27;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.
js8almost 9 years ago
Does that really correspond to usage in mathematics? I think that can be where the confusion comes from.<p>Let&#x27;s say: &quot;Here we define a function f(x,y) of two arguments x and y..&quot;
dandarealmost 9 years ago
Wait, don&#x27;t we have an <i>arguments</i> object in JavaScript that [&quot;is an Array-like object corresponding to the arguments passed to a function.&quot;](<a href="https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en&#x2F;docs&#x2F;Web&#x2F;JavaScript&#x2F;Reference&#x2F;Functions&#x2F;arguments" rel="nofollow">https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en&#x2F;docs&#x2F;Web&#x2F;JavaScript&#x2F;Referen...</a>)
评论 #12094101 未加载
aethosalmost 9 years ago
While this is true, be aware that parameter and argument are commonly used interchangeably.
uitgewisalmost 9 years ago
It takes an argument and you pass it a parameter.