Optional Parameters
Named parameters are often used in conjunction with optional parameters. Without named parameters, optional parameters can only appear at the end of the parameter list, since there is no other way to determine which values have been omitted. In languages that support named optional parameters, however, the programmer may supply any subset of the available parameters, and the names are used to determine which values have been provided.
An additional complication arises in languages such as OCaml that support both optional named parameters and partial application: it is impossible in general to distinguish between a partially applied function and a function to which a subset of parameters have been provided. OCaml resolves this ambiguity by requiring a positional parameter to follow all optional named parameters: its presence or absence is used to decide whether the function has been fully or partially applied. If all parameters are optional, the implementor may solve the issue by adding a dummy positional parameter of type unit.
Read more about this topic: Named Parameter
Famous quotes containing the words optional and/or parameters:
“Our father presents an optional set of rhythms and responses for us to connect to. As a second home base, he makes it safer to roam. With him as an allya loveit is safer, too, to show that were mad when were mad at our mother. We can hate and not be abandoned, hate and still love.”
—Judith Viorst (20th century)
“Men have defined the parameters of every subject. All feminist arguments, however radical in intent or consequence, are with or against assertions or premises implicit in the male system, which is made credible or authentic by the power of men to name.”
—Andrea Dworkin (b. 1946)