Parameter (computer programming)

In computer programming, a parameter, a.k.a. formal argument, is a variable that represents an argument, a.k.a. actual argument, a.k.a. actual parameter, to a subroutine call.[a].[1][2][3][4] A function's 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 def add(x, y): return x + y. Variables x and y are parameters. For call add(2, 3), the expressions 2 and 3 are arguments. For call add(a+1, b+2), the arguments are a+1 and b+2.

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.


Cite error: There are <ref group=lower-alpha> tags or {{efn}} templates on this page, but the references will not show without a {{reflist|group=lower-alpha}} template or {{notelist}} template (see the help page).

  1. ^ "Passing Information to a Method or a Constructor (Learning the Java Language > Classes and Objects)". The Java™ Tutorials. Retrieved 2021-09-09. 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.
  2. ^ Prata, Stephen (2004). C primer plus (5th ed.). Sams. pp. 276–277. ISBN 978-0-672-32696-7.
  3. ^ "Working Draft, Standard for Programming Language C++" (PDF). Open Standards. 2005-10-19. Archived from the original (PDF) on December 14, 2005. Retrieved 1 January 2018.
  4. ^ Gordon, Aaron. "Subprograms and Parameter Passing". rowdysites.msudenver.edu/~gordona. Archived from the original on 1 January 2018. Retrieved 1 January 2018.

© MMXXIII Rich X Search. We shall prevail. All rights reserved. Rich X Search