A type’s converter, r8converter(Type), is a function that converts a value to the type, and the generic of those conversions. implement(converter, source) <- function(x) ... declares the conversion from a class, such as "character", or from an R8 type object:
A package exports the converter under a name of its choice, such as as_resampler(), and documents it with roxygen2; the roclet r8rd() adds each conversion to the converter’s Rd file (Documentation with roxygen2). The method takes exactly one argument, x.
r8convert(x, Type) is the same conversion. It calls the method for the class of x and checks that the result is a value of Type:
implement(r8convert, Type) is an error that names the converter’s form. An impl of From is declared in the namespace of the target type or of an R8 source type, and an R8 source type is registered before the impl.
27.2 Conversion and extends
A value of a struct that extends another converts with the conversion from its own type, or else from its nearest ancestor’s, which receives the child’s value unchanged (Extending a struct). A conversion to a parent is never used for its child: a parent’s value is not a child’s.
27.3 Conversion and construction
A constructor takes each field in its type or in a form R8 converts natively, such as a double holding a whole number for an integer field (Structs). A conversion runs only when r8convert(), Type@from(), or a converter calls it, so a field of type Resampler takes a Resampler value, and as_resampler("kfold5") gives one from text.