Skip to contents

format() gives the text of a type object, or of an object that a declaration is written with, such as a field type or a rule, as lines, and print() writes them. The first line names the kind of object in angle brackets. Types are in one notation (integer [1, Inf), optional vector of double), and rules and defaults as R writes them.

Usage

# S3 method for class 'r8_type'
format(x, ...)

# S3 method for class 'r8_type'
print(x, ...)

# S3 method for class 'r8_field_type'
format(x, ...)

# S3 method for class 'r8_field_type'
print(x, ...)

# S3 method for class 'r8_host_class'
format(x, ...)

# S3 method for class 'r8_host_class'
print(x, ...)

# S3 method for class 'r8_field'
format(x, ...)

# S3 method for class 'r8_field'
print(x, ...)

# S3 method for class 'r8_rule'
format(x, ...)

# S3 method for class 'r8_rule'
print(x, ...)

# S3 method for class 'r8_calc'
format(x, ...)

# S3 method for class 'r8_calc'
print(x, ...)

# S3 method for class 'r8_variant'
format(x, ...)

# S3 method for class 'r8_variant'
print(x, ...)

# S3 method for class 'r8_params'
format(x, ...)

# S3 method for class 'r8_params'
print(x, ...)

# S3 method for class 'r8_trait_method'
format(x, ...)

# S3 method for class 'r8_trait_method'
print(x, ...)

# S3 method for class 'r8_impl_method'
format(x, ...)

# S3 method for class 'r8_impl_method'
print(x, ...)

Arguments

x

The object.

...

Not used.

Value

format(): Character, the lines. print(): x, invisibly.

Examples

op <- options(r8.namespace = "demo")
vec(type_double(min = 0), min_length = 1L)
#> <r8 field type> vector of double [0, Inf), length 1 or more
field(type_integer(min = 1L), default = 10L, description = "Number of folds.")
#> <r8 field> integer [1, Inf) = 10L
#>   Number of folds.
rule(lo <= hi, message = "lo is at most hi.", id = "ORDER")
#> <r8 rule ORDER> lo <= hi
#>   lo is at most hi.
Interval <- new_struct(
  "Interval",
  fields = list(lo = field(type_double(), default = 0), hi = type_double()),
  rules = rule(lo <= hi, id = "ORDER")
)
Interval
#> <r8 struct demo::Interval v1>
#>   lo: double = 0
#>   hi: double
#>   rule ORDER: lo <= hi
format(Interval)
#> [1] "<r8 struct demo::Interval v1>" "  lo: double = 0"             
#> [3] "  hi: double"                  "  rule ORDER: lo <= hi"       
options(op)