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).
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.
© MMXXIII Rich X Search. We shall prevail. All rights reserved. Rich X Search