# Parameter A parameter is a value that is needed (although it may be optional) by a [[procedure]] to perform its task. Parameters are often mistaken for [[Argument|arguments]], since parameters are the [[Variable]] inside the implementation of the [[procedure]] where [[Argument|arguments]] are the actual input expression passed to a [[procedure]]. ## In/Out There is three _parameter modes_: - `in`: an _input parameter_ is a read-only initialized value - `out`: an _output parameter_ is a non-initialized write-only value - `in out` or `inout`: an _input/output parameter_ is an initialized read-write value that can be altered. `in out` parameter are generally discourage in favor of return values. ```python # Don't def apply(fct: "procedural parameter", mutable_sequence: "in out parameter"): """Impure function.""" for i, obj in enumerate(mutable_sequence): mutable_sequence[i] = fct(obj) # Do def apply(fct: "procedural parameter", sequence: "in parameter"): """ Pure function. >>> apply(int, ["1", "42", "255"]) [1, 42, 255] This is for educational purpose, in Python and in this case, one would use a list comprehension instead of this function: >>> [int(obj) for obj in ["1", "42", "255"]] [1, 42, 255] """ result = [None] * len(sequence) # Pre-allocation for i, obj in enumerate(sequence): result[i] = fct(obj) return result ``` --- Bibliography: - [Parameter (computer programming) - wikipedia.org](https://en.wikipedia.org/wiki/Parameter_(computer_programming))