Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Parameter (computer programming)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Representation of an argument in a function definition}} {{Other uses|Parameter (disambiguation)}} In [[computer programming]], a '''parameter''', a.k.a. '''formal argument''', is a [[Variable (computer science)|variable]] that represents an argument, a.k.a. actual argument, a.k.a. actual parameter, to a [[subroutine]] call.{{efn|1=In this article, the term "subroutine" refers to any subroutine-like construct, which have different names and slightly different meanings depending on the [[programming language]] being discussed.}}.<ref name="Oracle">{{cite web | title=Passing Information to a Method or a Constructor (Learning the Java Language > Classes and Objects) | website=The Javaβ’ Tutorials | url=https://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html | access-date=2021-09-09 | quote=Parameters refers to the list of variables in a method declaration. Arguments are the actual values that are passed in when the method is invoked. When you invoke a method, the arguments used must match the declaration's parameters in type and order.}}</ref><ref>{{cite book|last1=Prata|first1=Stephen|title=C primer plus|date=2004|publisher=Sams|isbn=978-0-672-32696-7|pages=276β277|edition=5th}}</ref><ref>{{cite web|title=Working Draft, Standard for Programming Language C++|url=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdf|archive-url=https://web.archive.org/web/20051214034042/http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdf|url-status=dead|archive-date=December 14, 2005|website=Open Standards |date=2005-10-19 |access-date=1 January 2018}}</ref><ref>{{cite web|last1=Gordon|first1=Aaron|title=Subprograms and Parameter Passing|url=http://rowdysites.msudenver.edu/~gordona/cs3210/lects/lect10.html|website=rowdysites.msudenver.edu/~gordona|access-date=1 January 2018|archive-url=https://web.archive.org/web/20180101140104/http://rowdysites.msudenver.edu/~gordona/cs3210/lects/lect10.html|archive-date=1 January 2018|url-status=dead}}</ref> A function's [[function signature|signature]] defines its parameters. A call invocation involves evaluating each argument expression of a call and associating the result with the corresponding parameter. For example, consider subroutine <code>def add(x, y): return x + y</code>. Variables <code>x</code> and <code>y</code> are parameters. For call <code>add(2, 3)</code>, the expressions <code>2</code> and <code>3</code> are arguments. For call <code>add(a+1, b+2)</code>, the arguments are <code>a+1</code> and <code>b+2</code>. Parameter passing is defined by a programming language. [[Evaluation strategy]] defines the semantics for how parameters can be declared and how arguments are passed to a subroutine. Generally, with [[call by value]], a parameter acts like a new, local variable initialized to the value of the argument. If the argument is a variable, the subroutine cannot modify the argument state because the parameter is a copy. With [[call by reference]], which requires the argument to be a variable, the parameter is an alias of the argument.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)