Skip to main content

Module dots_policy

Module dots_policy 

Source
Expand description

#[miniextendr(dots = ...)]: typed_list!(...), or what the function’s ... is for (#2157).

An S3 method takes ... because its generic does, and R hands it every argument the method has no formal for. A method that reads none of them loses a misspelt one without a word: confint(fit, levle = 0.9) returns the 95% interval. The role says which arguments ... takes, and the generated R wrapper refuses the others before it evaluates anything:

dots =... takesthe Rust function
emptynothingreads no dots
empty(allow = ["optional"])the listed namesignores them
forward(allow = ["digits"])the listed namespasses them on to another R function
dataanything, uncheckedreads them

An argument the function reads is a parameter, not a name in ...: R then matches it by name or by position, as for any function.

An unnamed argument in ... is one of the generic’s arguments given by position (#2185). Under forward it passes: the function the dots go on to matches it by position itself. Under empty nothing reads it, so only the count matters: up to the number of allowed names not given by name are taken, and the rest refused.

class = "..." (or class = ["...", ...]) puts the package’s classes in front of the refusal’s own.

The check is one statement, if (...length()) .miniextendr_check_dots(...) (DotsPolicy::r_check), after the lifecycle notice and before the argument checks, so a misspelt argument is reported before a missing one (predict(fit, nwedata = nd) names nwedata, not the missing newdata). It reads ...length() and ...names() only, so no argument is forced. The helper is in the wrappers preamble (miniextendr_api::registry): one classed argument error for every refused argument, with the formal or listed name each one most likely meant.

Generated methods that have no attribute make the empty check too (DotsPolicy::empty, #2174): the [[, as.list() and [[<- field methods of s3(r_data_accessors) on a bare pointer, with the type’s field_error classes, and an env class’s [[.

Structs§

DotsPolicy 🔒
A parsed dots = empty | empty(..) | forward(..) | data.

Enums§

DotsAttr 🔒
The value of dots = ....
DotsRole 🔒
What the function’s ... takes (see the module docs).

Constants§

EXPECTED 🔒

Functions§

parse_dots_attr 🔒
Parse the value of dots = ....
parse_options 🔒
The allow = .. and class = .. options of empty(..) / forward(..), each at most once. Every problem is reported at once.
r_chr 🔒
An R character vector literal: character(), "a" or c("a", "b").
role_of 🔒
string_list 🔒
A string, or a non-empty array of distinct strings, none empty or holding a NUL. Names (allow) can’t be ... either.