Named parameter

Definition
A named parameter (also called a named argument or keyword argument) is a function or method argument that is identified by a distinct name rather than solely by its position in the argument list. When invoking a callable entity, the caller can specify values for these parameters using their names, thereby allowing arguments to be supplied in an order different from the formal parameter sequence and enabling omission of optional parameters that have default values.

Overview
Named parameters are a language feature employed in many modern programming languages to improve code clarity, reduce errors associated with argument ordering, and support optional arguments. Languages such as Python, C#, Ruby, Swift, Kotlin, and PHP provide built‑in syntax for named parameters. In some contexts—particularly in languages that historically used only positional arguments—named parameters are introduced via language extensions, libraries, or via the concept of “keyword arguments” (e.g., in Lisp, Common Lisp, and Clojure).

Typical usage patterns include:

  • Selective specification – supplying only a subset of parameters while relying on defaults for the rest.
  • Reordering – calling a function with arguments in an order different from the function’s declaration.
  • Self‑documenting code – improving readability by pairing each argument with its meaning explicitly.

Named parameters are often combined with default arguments; a parameter that has a default value can be omitted in the call, and the default is used instead.

Etymology/Origin
The phrase combines the adjective named (meaning “identified by a name”) with parameter (a term from mathematics and computer science denoting a variable that defines a function’s input). Early support for named parameters appeared in ALGOL 68 (1968) and later in languages such as CLU (1975) and Lisp (via keyword arguments). The terminology “keyword argument” arose in Lisp communities, while “named parameter” became the more general term in object‑oriented and imperative languages.

Characteristics

Characteristic Description
Identification by name Arguments are matched to parameters using the parameter’s identifier rather than its position.
Order independence The caller may supply arguments in any sequence, as long as each name is unique within the call.
Optionality Frequently paired with default values, allowing callers to omit arguments.
Type checking In statically typed languages, the compiler verifies that the supplied value matches the declared type of the named parameter.
Compatibility Some languages support both positional and named arguments in a single call, often requiring named arguments to follow all positional arguments.
Runtime overhead Implementations may require additional metadata (e.g., a mapping from names to values) which can affect performance, though many modern compilers optimize this.
Interoperability Named parameters facilitate inter‑language calls and API bindings by making the contract explicit.

Related Topics

  • Positional parameters – arguments matched by their order in the call.
  • Keyword arguments – a term synonymous with named parameters, especially in Lisp‑derived languages.
  • Default arguments – parameters that have predefined values if no explicit argument is supplied.
  • Variadic functions – functions that accept a variable number of arguments, sometimes combined with named parameters.
  • Function overloading – multiple functions with the same name but different parameter lists; named parameters can aid disambiguation.
  • Argument unpacking / spread operator – mechanisms to pass collections of arguments to a function, sometimes interacting with named parameters.
  • Reflection / introspection – runtime facilities that can enumerate parameter names, enabling advanced uses of named parameters.

This entry reflects the commonly accepted understanding of “named parameter” within computer science and software engineering literature.

Browse

More topics to explore