Skip to contents

params() reads its call unevaluated. Each argument declares one parameter, in order:

Usage

params(...)

Arguments

...

The parameters. The first is a name, the value that the generic or method dispatches on.

Value

An r8_params, for generic() and trait_method().

Details

  • x, a bare name: a parameter without a type or a default.

  • n = arg_integer(min = 0L, default = 1L), a call of arg() or one of its shorthands: a typed parameter.

  • n = length(x), any other expression: a parameter without a type whose default is the expression.

  • "...", a string: the dots, through which methods add arguments of their own.

A default is evaluated at each call that omits the argument, in the generic's frame, where the other parameters are visible, and then in the environment that calls params(); nothing but the types is evaluated when params() runs. A constant default, such as 1L, "a", or c(1, 2), of a typed parameter is checked against its type at the declaration and belongs to the declaration that other languages read; a call from another language supplies an argument whose default is any other R expression.

Examples

params(x)
#> <r8 params>
#>   x
params(x, y, n = arg_integer(min = 1L, default = 10L), "...")
#> <r8 params>
#>   x
#>   y
#>   n: integer [1, Inf) = 10L
#>   ...
params(x, n = arg_integer(default = length(x)))
#> <r8 params>
#>   x
#>   n: integer = length(x)