Parameter (computer programming)

Unlike argument in usual mathematical usage, the argument in computer science is the actual input expression passed/supplied to a function, procedure, or routine in the invocation/call statement, whereas the parameter is the variable inside the implementation of the subroutine.The semantics for how parameters can be declared and how the (value of) arguments are passed to the parameters of subroutines are defined by the evaluation strategy of the language, and the details of how this is represented in any particular computer system depend on the calling convention of that system.For example, in C, when dealing with threads it is common to pass in an argument of type void* and cast it to an expected type: To better understand the difference, consider the following function written in C: The function Sum has two parameters, named addend1 and addend2.It adds the values passed into the parameters, and returns the result to the subroutine's caller (using a technique automatically supplied by the C compiler).At runtime, the values assigned to these variables are passed to the function Sum as arguments.The values of the arguments are added, and the result is returned to the caller, where it is assigned to the variable sum_value.Any of these situations causes a mismatch between the parameter and argument lists, and the procedure will often return an unintended answer or generate a runtime error.Within the Eiffel software development method and language, the terms argument and parameter have distinct uses established by convention.Some programming languages such as Ada, C++, Clojure,[citation needed] Common Lisp,[9] Fortran 90,[10] Python, Ruby, Tcl, and Windows PowerShell[citation needed] allow for a default argument to be explicitly or implicitly given in a subroutine's declaration.Some languages allow subroutines to be defined to accept a variable number of arguments.The exact requirements and enforcement vary between languages – for example, in Ada 83 output parameters can only be assigned to, not read, even after assignment (this was removed in Ada 95 to remove the need for an auxiliary accumulator variable).Syntactically, parameter mode is generally indicated with a keyword in the function declaration, such as void f(out int x) in C#.[16] A syntactically similar construction to output parameters is to assign the return value to a variable with the same name as the function.An archetypal example is the TryParse method in .NET, especially C#, which parses a string into an integer, returning true on success and false on failure.Output parameters are often discouraged in modern programming, essentially as being awkward, confusing, and too low-level – commonplace return values are considerably easier to understand and work with.Thus one must initially declare a variable, and then each step of a chain of functions must be a separate statement.
Parameter (disambiguation)computer programmingvariablesubroutinedefinition of a subroutineargumentevaluation strategycalling conventioncall by valuecall by referenceC programming languagedouble-precision floating pointdeclarationliteralpass-by-referencepass-by-valuerun-timeruntime errorEiffelgeneric classesdictionarystrongly typed programming languagestype inferencetype theoryClojureCommon LispFortran 90PythonWindows PowerShelldefault argumentvariable number of argumentsnamed parametersself-documentinglambda calculuscurryingHaskellsyntactic sugarFunction applicationleft-associativeFortranPL/SQLTransact-SQL.NET FrameworkTScriptAda 83Ada 95denotational semanticsoperational semanticsreturn valuePascalFortran 66Fortran 77semipredicate problemexception handlingfunction compositionparallel assignmenttagged unionnullable typesoption typescall by sharingCommand-line argumentOperator overloadingFree variables and bound variablesprogramming languageObject-Oriented Software Construction