Skip to contents

R8 0.6.0.9000

R8 0.6.0

  • Exported functions that operate on values, types, tables, and packages begin with r8 joined to their first word, with underscores between the later words: r8filter(), r8set(), r8check(), r8to_json(), r8is_variant(), and the roclet r8rd(). Classes and conditions begin with r8_: r8_value, r8_table, and r8_value_error.
  • A typed function whose body is rust() has its body in its package’s Rust code: a function marked #[r8::function] and listed in functions of r8::exports!. The declaration in R stays the function’s, its schema included; each call checks the arguments, calls the Rust function, and checks the result, and loading the package compares the Rust function’s signature with the declaration.
  • r8rust_signature(f) writes the Rust signature of a typed function, for its body in Rust.
  • Compiled methods and function bodies take &[f64], &[i32], &[u8], &[bool], and &str, borrowed from the R value for the call, and #[r8(name = "...")] gives a parameter an R name; a Vec result is a plain R vector.
  • A typed call checks a vector of logicals, integers, or doubles in place, and a typed function with a return type runs its body in its own frame as written.
  • arg() and its shorthands take description, which the declaration keeps; arg(description = ) alone describes a parameter without a type. The roclet r8rd() writes a described parameter’s @param from it, and refuses a block that also documents that parameter.
  • r8schema(x) writes the JSON Schema of the arguments of a typed function, for a tool’s input schema; its first argument is x, a type or a typed function.
  • r8check_call(), r8call_from_json(), and r8call_to_json() check, run, and write documents of a call of a typed function, {"$function": "ns::f", "arguments": {...}}, among the functions that the caller names.
  • The declaration record has format 10; a package installed with an earlier R8 is reinstalled.
  • A shorthand of arg() takes default and description by name, and a parameter is not named .Call, quote, environment, withVisible, or invisible. A constant default of c() mixes no kinds of element, and pkg::Type as a default is refused as Type is.
  • A return() inside local() or evalq() in the body of a typed function returns from that call, unchecked.
  • A rule’s error writes each value it found once, and leaves out a value that it does not show, such as levels(x).
  • A package whose Rust declarations panic raises an error at library(). A package’s Rust code stays loaded after pkgload::unload(), so its values remain valid, and an R object that Rust code keeps is copied, not changed, by R’s replacement functions.
  • A description of several lines prints each line indented.
  • A missing value names the type it lacks: “n must be a value of type integer [1, Inf); found NULL.”
  • A Rust-stored value whose buffer Rust owns writes a field without starting a collection of R’s garbage: each value that shares the buffer counts a share of its bytes.
  • A default prints in one R form in a field object, a parameter, and a type: a date as as.Date(), a date-time as as.POSIXct(), and each double with the fewest digits that identify it.
  • host_class(class, package, system = "s7"), and an S7 class object, declare an argument, a result, a field, or a dispatched position of an S7 class.
  • r8is_variant() of a value whose package is not loaded refuses a name that is no variant, as with the package loaded, by the declaration that the value carries.
  • A package with Rust code built against an earlier R8 of the same ABI version loads after R8 appends members to its C tables, which a reader finds absent.
  • An error that a package’s compiled code returns, from a compiled method or the Rust body of a typed function, is an r8_compiled_error, with its code in the field code, and a panic an r8_panic.
  • A value that a package’s Rust code makes is validated when its type has rules, constraints, or subtype() or dyn() fields, and the method that made it raises the error.
  • calc(expr) declares an expression of the rule dialect as a value. r8set(x, list(bmi = calc(weight / height^2))) stores the column that it computes in Rust, with the unit that the expression infers, and r8set(x, columns, by) evaluates its aggregates over each row’s group.
  • r8summarize(x, columns, by) gives one row for each group of the rows of a table, in the order of the keys, with the summaries that calc() values of n(), count(), sum(), mean(), median(), min(), and max() compute; na.rm = TRUE leaves out missing cells.
  • r8map(x, f, columns, by), a generic, maps a typed function of R8, or a calc() in which col() is the column, over the columns of a table, one row for each group. An impl for Raven applies to every table. On a table, a typed function’s map is that of calc(f(col())), and args gives one value to each parameter. At verbosity = 1L, its default, a map that takes longer than 0.2 s writes a start and an end line saying where it runs, in Rust, in R, or both, with the wall time, CPU time, and threads at its end.
  • r8explain(call) gives the plan of a call of r8map(), r8summarize(), or r8set() before it runs: its stages, where each runs, in Rust or in R, the typed functions it calls with the languages of their bodies, and the calls, with the engine of the whole call and a plan hash; format(plan, "mermaid") writes the plan as a Mermaid flowchart.
  • r8bench(expr) evaluates expr once and gives the wall time, the CPU time of R’s process, the most memory that the process held, and the cores that it may use, with, for each call of r8map(), r8summarize(), or r8set() that expr runs, the plan of its run: each stage’s status, first start, last end, and busy seconds, and a failed stage’s group, first row, and message. It prints as one line.
  • A progress hook with the function stages(handle, plan) receives the plan of a map’s run before end().
  • r8map(x, f, args = list(...)) of a list or an atomic vector calls a typed function on each element, with the constant arguments of args, and gives an atomic vector or a list by the function’s return type, with the names of x.
  • A map of a typed function reports its progress to the functions of the option r8.progress, begin, update, and end, which a host such as rtemis.core draws; a map that ends within 0.2 s reports nothing.
  • The rule dialect has ^, median(), n(), count(), NA, na.rm = TRUE in aggregates, and col(expr), the column whose name an R expression gives.
  • A calc() calls a typed function of new_function() for each group, or over all rows: r8summarize(x, list(sbp = calc(trimmed_mean(sbp, trim = 0.2))), by = "ward"). A parameter of vec(T) takes the group’s cells and a scalar parameter a constant, and each call is checked as a direct call. A body in Rust is called from R8’s Rust code, without R, and runs at most once for each call.
  • field(compute =) takes a calc(): field(option(type_double()), compute = calc(mg / 1000)).
  • aggregate() of a table is an error that names r8summarize().
  • n_threads of r8map(), r8summarize(), r8set(), r8sort(), r8filter(), and r8check(), and the option r8.n_threads, set the threads that their work in Rust may use; a result is the same for any number of threads.

R8 0.5.0

  • The IR holds the lowering of extends: a child’s rules carry inherited_from as its fields do, and the field type {"kind": "subtype", "of": "ns::Parent"} admits a struct and every struct that extends it. The declaration hash of a child covers its flattened fields and rules.
  • The declaration record has format 8; a package installed with an earlier R8 is reinstalled.
  • new_struct(extends = Parent) declares a child that holds the parent’s fields and rules, then its own; defaults = changes the defaults of inherited fields. A child’s values carry the parent’s class after their own, and a field typed as a struct admits that struct only.
  • A struct whose fields all have defaults that violate its rules is a declaration error (default_violates_rule).
  • Declaring a parent again leaves the children that extend its earlier declaration stale: they construct and read no values until they are declared again, and the declaration warns (r8_stale_warning). A package built against an earlier declaration of another package’s parent is refused at load.
  • A package’s declaration records declare only into the namespaces it owns; a declaration of another package’s type in them is skipped.
  • to_json() is r8_to_json(): a function a declaration is written with takes no prefix, and an operation on values, types, or packages takes r8_ (?R8, section “Names”).
  • generic(name, params) and trait_method(params) take their parameters from params(), which reads its call unevaluated: a bare name x, a default n = length(x), a typed parameter n = arg_integer(min = 0L, default = 1L), and "...". A method of a generic without ... has exactly the generic’s parameters; a method of a generic with ... takes them first and may add named arguments. impl() checks its methods’ arguments as implement() does, and trait_method(default_impl =) checks its default’s.
  • arg(type, default) declares a parameter’s type and default, with a shorthand per type constructor: arg_double(min = 0, default = 1), arg_vec(type_integer()), arg_option(type) with the default NULL. A constant default is checked against its type at the declaration.
  • A call of a typed generic forces, checks, and converts its typed arguments before it dispatches, and raises r8_argument_error with every problem of every argument; a default that fails is named by its expression. A result that does not satisfy the return type raises r8_result_error, and an invisible result stays invisible. Two scalar arguments add 0.19 µs to a call, and a result 0.32 µs.
  • A parameter’s default is evaluated in the generic’s frame, then in the environment that calls params(). A generic is enclosed by that environment, so a generic sent to a worker loads the package that declares it; a package that masks .Call, $, or quote is refused (base_masked).
  • print() of a generic and of a trait shows the types, defaults, and return types, in one notation: n: integer [0, Inf) = 1L, w: optional vector of double. The roclet r8_rd() begins each @param of a typed parameter with its type and writes the return type as the value of a block without @return.
  • A value that is not a subtype() or an implementor of a dyn() trait is reported by what it is, with the codes not_subtype and not_implementor.
  • A method gives no default to a parameter of its R8 generic (method_default); its own arguments after ... and the methods of S3 generics keep theirs. A trait method that maps an S3 generic declares names only, without types, defaults, and a return type (mapped_generic).
  • generic(return_type =) and trait_method(return_type =) declare the type of the value that every method returns, or "Self"; implement(f, Type, return_type = T) <- fn and impl_method(fn, return_type) declare a method’s own, which fits it.
  • implement() and r8_method() take the generic as their first argument, without a name, so implement(connect, g = Graph) <- fn names the dispatched parameter g; a dispatched parameter is not named return_type or value.
  • A field’s default is an R value of its type, such as a Date, a raw vector, Inf, or a named vector for a map; a default that is not one is a declaration error (default_invalid).
  • Print headers name R8 and the object’s kind: <r8 generic ns::f>, <r8 struct ns::P v1>, <r8 enum ns::E v1>, <r8 trait ns::T>, <r8 int64>, <r8 field type>.
  • ?R8 lists R8’s condition classes, r8_codec_missing_error among them.
  • A generic or trait method called on a child runs the impl of the nearest type in its chain of parents that implements the trait, on the child’s value. r8_next_impl() calls the impl the running one takes precedence over.
  • r8_upcast(x, Parent) returns the value of an ancestor that a child’s value holds, and r8_convert(x, Parent) calls it; r8_ancestors() lists a struct’s ancestors. An impl of From() from a child to its ancestor is a declaration error.
  • #[derive(R8)] declares a struct that extends another: its first field, marked #[r8(extends)], embeds a struct of #[r8(extensible)], and inherited(name(default = "...")) changes an inherited default. The derive writes the interface trait <Parent>Like, which the parent and every struct that extends it implement: an accessor per field, to_<parent>(), and with_<parent>(value), the value with another value of the parent. The types of a child’s own fields are Clone.
  • #[r8::methods(trait = "ns::Trait")] marks the Rust trait, and an impl takes no attribute: a row of r8::exports! names the type and the trait, and registers an impl over an interface trait, such as impl<T: IntervalLike> Shifted for T, for that type. A method returns a Rust-stored value as itself, -> Self included, and r8::Value is removed. r8::exports! defines r8_init_<package>() in place of r8_init(), so a crate with exports is a dependency of another package’s crate.
  • A Rust-stored struct may extend another, r8_upcast() takes a Rust-stored value, and an impl in Rust for a struct applies to the structs that extend it. r8_document_rust() writes extends =, defaults =, and subtype() fields.
  • R8.h: a codec names its module, the compiled code that reads its states, and R8 lends a state to that code only: value_state and new_value take the caller’s module, upcast_state lends the state of an ancestor (R8Codec.upcast), and new_value leaves the state to the caller when it returns an error.
  • dyn(Trait) declares a field of any implementor of a trait, or of a type that extends one, and subtype(Struct) a field of a struct or any struct that extends it; dyn() takes traits only. A value of another type is refused (not_implementor, not_subtype), and its JSON names its type by the trait’s tag member, or by "$type".
  • A tag value is a name, unique among a trait’s implementors (duplicate_tag); a descendant without its own impl writes its type name. Inside dyn(), a unit-only enum is written as an object of the type member and its tag.
  • r8_from_json(load =) loads packages before the read; a document that names unregistered types raises r8_unknown_type_error, which names the installed packages that declare each namespace.
  • r8_schema(type, closed = FALSE) writes the JSON Schema of a type’s values; with closed = TRUE, a dyn() field lists the registered implementors and a subtype() field the struct and its registered descendants, annotated "x-r8": {"closed": "registered"}.
  • A replacement method (f<-) returns a value of its argument’s type, the child for a child’s value; another result raises r8_result_error, a subclass of r8_type_error. A From impl’s result of another type also raises r8_result_error.
  • A field of option(host_class("lm")) holds an object whose class vector contains "lm" only; another object is refused.
  • A symbol or a call given to a generic is dispatched on as a value, without evaluating it, and a symbol, a function, or an environment given to a constructor is refused with an R8 error.
  • generic("labels<-", params(x, value)) declares a replacement generic, called as labels(x) <- value; its trait is ns::with_labels. A method f<- is named with_f in the other bindings, and two methods of one namespace that share that name are a declaration error.
  • r8_next_impl() continues every impl R8 registers, S3 methods declared with implement() or impl() and Print impls included; it passes the current values of the impl’s arguments.
  • new_trait() refuses the methods names<-, length<-, dim<-, levels<-, and [<-, as implement() does.
  • r8_convert() uses the From impl of a value’s nearest ancestor when its own type has none, and passes the value unchanged.
  • A converter from r8_converter(Target) is the generic of the conversions to Target: implement(as_target, Source) <- function(x) ... and implement(as_target, "character") <- function(x) ... declare them, and the roclet r8_rd() documents them. Enum@from converts to an enum, and from is a reserved variant name.
  • From(Source) names an R8 type by its type object, and the source’s namespace may declare the impl; From() takes a class as a dispatched position does.
  • The IR’s method parameters may carry a dispatch mark, a type, a default, and a description, and a method a return type; an impl’s type_args are typed positions (TypeRef), an R8 type, a host class, or any.
  • An impl of a trait and type tuple that another namespace declares is refused (duplicate_impl), and an impl outside its trait’s namespace names a type of its own namespace (impl_orphan).
  • generic(dispatch = c("x", "y")) and trait_method(dispatch =) dispatch on several arguments: implement(f, A, B) <- fn, implement(f, y = B) <- fn, and impl(Trait, list(A, B), ...) declare methods for tuples of types, and a position a method does not name matches any value. The most specific method in every position runs; a call that two methods make ambiguous raises r8_dispatch_error naming the method to declare, and r8_ambiguities() lists such pairs. A package whose methods make a call ambiguous with those of a package it imports is refused at load.
  • r8_method(f, A, B) returns the method of a tuple, and r8_next_impl(A, B) continues to the method it names.
  • A value without a class attribute, such as a number or a matrix, keeps its selected method in the dispatch cache.
  • R8 generics and traits take methods for classes of other class systems in every dispatched position: a string names an S3 or implicit class (implement(f, "data.frame") <- fn, "matrix", "NULL"), and host_class(class, package, system = "s4") or an S4 class object names an S4 class; host_class(system =) is "s3", "s4", or "implicit". The class nearer the front of an object’s .class2() vector is more specific.
  • An impl on a class that already has a method of a mapped S3 generic takes that method; supplying one is refused (host_method_exists). r8_next_impl() from an impl on a class continues to the next S3 method.
  • dyn(generic) declares a field of any R8 type with a method of a generic of one dispatched argument; a dyn() field holds R8 values only.
  • r8_convert() reads an object’s classes with .class2(), so From("numeric") converts integers and doubles, and an impl on an S4 superclass converts its subclasses.
  • r8_clear_dispatch() clears the dispatch cache.
  • btree_map() and index_map() replace hashmap() and ordered_map(): string keys in code-point order, equal by key, and string keys in insertion order, part of the value.
  • option(T) declares that a value may be absent; a struct field’s fill policy is field(option(T), compute = expr) or field(option(T), context = TRUE), which r8_resolve() fills.
  • column(type, ..., unique, required) declares a table column; field() takes no unique or optional.
  • new_struct(storage = "rust") and new_enum(storage = "rust") replace native = TRUE; r8_document_rust() replaces r8_document_native(), and #[r8(storage = "rust")] replaces #[r8(native)].
  • The standard trait PartialOrd’s method is partial_cmp, called by r8_partial_cmp(), which returns -1L, 0L, 1L, or NA for values that are not ordered; <, <=, >, and >= return FALSE for those, and any other result raises r8_result_error.
  • The standard trait Dim is Shape.
  • Compiled impls dispatch on several arguments: a type parameter of the Rust trait is a dispatched position, #[r8::methods(trait = "ns::meets", dispatch(x, y))] trait Meets<Y>, and a row names the types, Interval: Meets<Band>, or Interval: Meets<r8::Any>. r8::From<Source> converts a value of another type, and a replacement method f<- is with_f(&self, value).
  • R8.h: an impl entry holds its positions (R8Position: a type, a class of R, or any value) in place of its type’s name. An impl in compiled code defines every method of its trait without a default implementation, as impl() requires.
  • A field of a Rust-stored type is a Rust-stored type, r8::SubtypeValue<P> (subtype(P)), or r8::ImplementorValue<dyn Trait> (dyn(Trait)), beside the scalar and Buffer types. A holder keeps the R value, of a type that the package’s code does not know too, reads it as P, and gives the value of a type that the code names (downcast_ref()). #[r8::methods(trait = "ns::Trait", dyn)] names the trait, and r8_document_rust() writes dyn() fields. rtemis_r8::derive::SubtypeOf<P> and ImplementorOf<dyn Trait> hold such values as JSON, with to_document_in() and from_document_in().
  • r8::exports! { traits = [...] } lists the traits that Rust declares: types from the Rust signatures, #[r8(min = 0, default = "1")] and doc comments on parameters, #[r8(name = "f<-")], tag = "...", and accessors of required fields marked #[r8(field)]. r8_document_rust() writes their generic() and new_trait() calls, and r8_register() compares the declarations.
  • A package’s load checks the signature of each method in Rust against its trait: the names of the parameters, their types, and the result’s (impl_signature). A method takes SubtypeValue<P>, ImplementorValue<dyn Trait>, and Option<&T>, and a method that returns a narrower type than its trait declares has that return type.
  • R8.h: an impl entry holds the signatures of its impl, and the exports table the size of an entry; a package built against an earlier header is refused at load.
  • Compiled methods and Rust-stored types of a package are written in Rust, through rtemis-r8-api; R8.h is the interface between that crate and R8, and an R method calls C or C++ code with .Call(). R8 refuses an exports table written by hand: a codec outside the declaration record, without from_reader, an impl entry without a signature, and one for a class of R.
  • Rust code reads the fields of a value of another package’s type by name, and only when the registered declaration admits no value that the compiled one does not. Other differences warn when the package loads (r8_declaration_warning) and are errors at a read (declaration_changed); before, a package compiled against an earlier order of the fields read other fields.
  • ?new_struct and the user guide state how a type that other packages use changes.
  • A method in Rust returns a value of another package’s Rust-stored type, which R8 builds from its fields.
  • A nested value of a Rust-stored type, read from JSON, is a Rust-stored value.
  • A value read by readRDS() before its package is loaded names the package of each value that it holds.
  • R8.h: R8Reader.value gives the R value of a node; R8Api.value_of_fields builds a value of any registered type from its fields, and R8Api.with_fields replaces fields of a value, validated. A package with compiled exports is reinstalled.
  • The result of a method that returns a buffer, and a value read by unserialize(), are protected while R allocates.
  • A problem of a package’s declarations is reported once.
  • Type objects and the objects a declaration is written with (rule(), field(), column(), variant(), trait_method(), params(), impl_method(), and the field types) print in one notation, with their defaults, descriptions, and rules: <r8 field> integer [1, Inf) = 10L, <r8 rule ORDER> lo <= hi. format() gives the lines, of a type object too.
  • An error of a compiled method reports the call of the generic, ratio(s, 0).
  • x[c("a", "b")] <- list(v, w) replaces several fields of a value: each is checked, then the rules that read any of them, once. replace(x, c("a", "b"), list(v, w)) is the form in an expression.
  • as.list(x) gives a value’s fields as a plain named list, so lapply() and vapply() take a value. x[c("a", "b")] reads fields by name; a name that is not a field, and an index that is not a name, are errors. inherits(x, Type) tests for a value of a type or of a struct that extends it.
  • An impl of a trait that is not registered, in R or compiled, is an r8_declaration_error that names the package to import from in NAMESPACE.
  • r8_variant(x) returns the name of an enum value’s variant. r8_is_variant(x, variant) tests for one, and a name that the enum does not declare is an error; is_variant() is a word of the rule dialect only.
  • trait_method(default_impl =) gives the trait’s default implementation of a method.
  • impl(trait, target, ...), type_table(of = Struct), type_matrix(of = Struct), and r8_runtime_version() replace impl(trait, type, ...), type_table(Struct), type_matrix(Struct), and r8_core_version().
  • new_trait(required_fields = list(...)) declares the fields every implementor has; an impl for a struct without a required field, or with one of a type that does not fit, is refused (required_field_missing, required_field_type).
  • type_r() is removed: option(host_class("lm")) declares a field that holds an R object of another class system, host-only: R holds it, a document writes null, and the content hash leaves it out (codes host_only, host_outside_option, and host_resolve).
  • dyn(trait), subtype(struct), and r8_css(style_element =) name their arguments; r8_css(tag =) is style_element.
  • The condition classes r8_codec_missing_error and r8_unknown_type_error end in _error; the validation code of a type that no registered type has is unknown_type.
  • The IR: the member of values = is values; a variant’s form is its kind; an R8 type in a field or an impl is {"kind": "named", "name": ...}, and a host class {"kind": "host_class", "host", "package", "class", "system"}; a trait’s type parameters beyond Self are extra_type_params; an impl has no codec. A document’s envelope is "$type" and "$types".
  • R8.h: the codec of a Rust-stored type is R8Codec, whose member owned_bytes reports the bytes a state owns; the reader’s member function is R8Reader.member; an impl function receives R8CallInputs, with R8_CALL_HAS_SEED. In the crate rtemis-r8-api, RustStoredStruct and RustStoredEnum are the two kinds of Rust-stored type and RustStored either.
  • The IR: a parameter’s host_default is a default written in a host’s language (default_host_both with a JSON default); an impl’s methods take {"name", "return_type"}, a return type that fits the trait method’s (return_type_unfit); a dispatched parameter’s type is an R8 type, subtype(), dyn(), or host_class(), and admits only the impl positions it names (dispatch_param_type). A parameter’s "default": null is the default of an option() parameter, apart from a required parameter; ... takes no type and no default (param_dots), and a replacement method no return type (return_type_replacement).
  • field(external =) is removed; the error codes of values = and type_posixct() are not_in_values and invalid_posixct.
  • A value carries its type, its variant, and the declaration that it was made under in an ALTREP object, where R code does not reach; its attributes are names and class. A list with the attributes of a value, as dput(), copied attributes, and serialize(version = 2) give, is refused where a value is expected.
  • The class vector of an enum value begins with its variant, ns::Type@Variant.
  • A value made under another declaration of its type than the registered one prints and gives its fields, and every use of it is an error that lists what differs (r8_other_declaration_error, or r8_value_error with the code declaration_changed); r8_update() gives its value under the registered declaration where its fields mean the same. A change of descriptions, of defaults, or of a rule’s ID or message leaves the values made before as they are.
  • A value saved with an earlier R8 is read again from its source or its document.
  • r8_to_json() writes $declarations, the hash of what each declaration says about a value, and, with declarations = TRUE, the declarations themselves. r8_from_json() refuses a document of another declaration than the registered one, unless the declarations it holds give its fields the same meaning, or declaration = "any" is passed.
  • A value, a field type, and a rule’s expression nest at most 100 levels (too_deep), and a default that holds itself is a declaration error (default_recursive).
  • A string in Latin-1 is translated to UTF-8 for documents, hashes, and equality; bytes that are no text are an error (r_encoding). r8_from_json() refuses an object that is not text.
  • A long validation, hash, comparison, document, filter, order, or gathering of rows ends at the user’s interrupt and at R’s time limits.
  • type_array() without dim takes an array of any number of dimensions.
  • r8_filter(x, rule) and r8_select(x, columns) choose the rows and the columns of a table, and x[rule, columns] is the same: a rule() is an index of rows. A rule is a value, which filters every table that has the columns it names; !, &, and | make a rule of others. A name in x[i, j] is R’s.
  • Rules over rows are evaluated by column in Rust, in filters and in the validation of a table’s rules. A comparison of two columns of 10^7 doubles with numbers takes 12 ms with the choice of the rows, against 42 ms for R’s condition.
  • Rules gain mean(), sqrt(), log(), exp(), is.na(), pmin(), and pmax(). In a filter, mean(), sum(), min(), and max() read the whole column; in a table’s declaration they are refused (rule_aggregate), and is.null() of a cell is refused with is.na(). sum() is the exact sum, rounded once.
  • In a rule, FALSE && NA is false and TRUE || NA true, in either order, as in R, and an operand that decides absorbs an error. A comparison with NaN is missing. A missing element makes sum(), min(), and max() of a vector missing.
  • In a row rule, the cell of a factor is its label: stage == "II"; a label that is no declared level is a declaration error (rule_level). A string compared with a date or a date-time is one (rule_date), and val() takes a Date and a POSIXct.
  • In a rule, a name with a dot is one name, such as the column Petal.Width, and $ makes a path.
  • type_double(infinite =, nan =) replace finite: infinite = TRUE admits the infinities within the bounds, and nan = TRUE admits NaN, whatever the bounds are. NaN where the type does not admit it is nan_value, with the number of such elements, and infinite that the bounds or the values leave nothing to is a declaration error (infinite_unused). In Rust, #[r8(infinite, nan)]; in the IR, "infinite" and "nan".
  • The problems of one kind in the elements of a vector are one entry of an error.
  • A column of a table that is replaced has no unit and no description but its type’s, and an error of a declared column gives the ways to store a transformed one.
  • val() replaces lit().
  • A row rule that reads a column that a table may leave out holds for a table without it.
  • A rule that ends in an error, such as a division by zero, shows the rule, the values it read, and the rows.
  • A derive(R8) rule takes abs, sum, and nchar.
  • A table prints as a grid with the types, units, and missing cells of its columns, its first and last rows, and what it leaves out.
  • new_table() declares a table, a type whose values hold columns, and Raven is the table of any columns. A table reads as a list of its columns and, with x[i, j], as a data frame; it shares the vectors that it is made from, and copies those of a data.table. r8_columns() describes the columns, and r8_annotate() gives them units and descriptions. r8_set(), r8_drop(), and r8_rename() give a table with columns added, replaced, removed, or renamed, and r8_sort() one with its rows in order.
  • The extra columns of an open type_table() have any name that does not begin with $, and a double column among them holds NaN and infinite values.
  • A field asked for by position is an error that gives the call by name: “field 1 is id: r[[”id”]]”.
  • Names that repeat are refused: two columns of a table (duplicate_column), two keys of a btree_map() or two members of a type_json() value (duplicate_key), and two members of one name in an object of a JSON document.
  • implement() takes a generic that does more than dispatch, such as as.data.frame(), sort(), dplyr::filter(), and data.table::as.data.table().
  • A Rust-stored value is saved as its fields, which read without the package that declares the type, and after the type changed; R8 checks them before Rust code takes the value. R8Codec.write_state, read_state, and encode, and R8Writer, are removed, and the interface is ABI version 2: a package with compiled exports is reinstalled.
  • No operation copies a vector, a matrix, a factor, or a column of a data frame, unless the field’s type asks for other elements; a POSIXct in another time zone is shared and read in UTC.
  • A field read gives a vector as a view that R copies before it changes it, and a table as a data frame of its own, so that setDT(), :=, and setattr() on what a read gave leave the value as it is. The columns of a data.table given to a constructor are copied; vectors and data frames are not.
  • r8_check(x, against) holds a table, or a data frame as it was read, against rules or a type, and gives a report: the rows that hold, fail, have no answer, and are errors, for each rule, and the problems with their rows, values, and explanations. r8_validate(x, against) holds any object against a type or rules, and raises an error; of a table against a table type, the error lists the problems of its columns and rows.
  • The name of a rule in a list is its ID, in a declaration and in a check: rules = list(order = rule(lo <= hi)).
  • new_function(name, fn, rules, return_type) declares a typed function: the types of its parameters are arg() and its shorthands in the formals of fn, each call checks and converts its arguments and checks its result in the function’s own frame, and the function is registered under its name; typed = "strict" asks a type of every parameter. The declaration record is format 9.
  • generic() and trait_method() take rules over their typed parameters, which each call checks before the method is chosen.
  • .table_type() and .report_types() give a package that reads files the columns of a table type and the types of a report.
  • r8_to_data_frame() is as.data.frame() of a table. as.matrix(), t(), is.na(), summary(), duplicated(), and model.frame() read a table as a data frame; unique(), split(), and na.omit() give tables; and cbind(), transform(), within(), subset(), and sort() are errors that name the function of R8.
  • A number with a sign is a constant in a rule: rule(y == -1), rule(y %in% c(-1, 1)).
  • TRUE or FALSE is asked for where an argument of a declaration is a flag, such as unique = and nan =.
  • A string that is no text is refused in a character vector and in a column (r_encoding), as it is in a field of one string.
  • A table has at most 2,147,483,647 rows (row_limit), and a data frame with a missing column name is refused.
  • r8_write_rds() and r8_read_rds() write and read an RDS file with a checksum: a damaged file is an r8_file_error.
  • print(), format(), and str() of a value show <sensitive> for a field declared sensitive = TRUE.
  • A constructor builds a default that is a value of another package’s type from the registered declaration of that type.
  • A value of a struct that its parent’s change left stale refuses a field write and a comparison.

R8 0.4.0

  • Rust-stored enums: #[derive(R8)] with #[r8(native)] on an enum of unit, struct, and newtype variants keeps every value, unit variants included, in compiled code. new_enum(native = TRUE) declares one in R, and r8_document_native() writes it.
  • R8.h: an enum’s codec sets the new members variant and from_variant of R8TypeVTable.
  • r8_register() refuses a codec whose shape does not match its type, and a codec whose enum declares a runtime-only field in any variant.
  • R8.h: an exports table carries the declarations of its types in Rust only, and R8 builds each impl declaration from the impl entries; a table written in C declares its types in R and carries no IR (ir_json is removed). A codec written in C sets declaration_hash, the hash of its type’s R declaration, which r8_register() checks, reporting the current hash when the two differ.
  • r8::exports! declares every type of the package’s namespace that its listed types reach, such as the struct of a newtype variant.
  • print() and str() of a Rust-stored value show its size in the header, in IEC units (<pkgc::Signal> 7.63 MiB); str() adds the fields read into R (+ 112 B read).
  • A method of #[r8::methods] takes another value of a Rust-stored type as &T, borrowed from its state, or built from an R-stored value of the type.
  • r8_document_native() writes a field whose type belongs to another package’s namespace as that package’s exported type object (r8resample::Resampler); the package lists it in Imports.
  • The roclet r8_rd() documents the methods a package implements in compiled code, as it documents implement() calls.
  • Text output: the Rust core lays out and encodes values as plain text, ANSI color, HTML, or markdown. print() chooses the output type for the console, document, or notebook (r8_output_type()), and format() returns plain text unless asked. The default layout shows each vector’s type, length, and first items, colors the names of base types after rtemislive, and indents nested values.
  • r8_layout() returns the layout of a value, a list, or a data frame; r8_span(), r8_text(), and c() build styled text, which a Display or Print impl may return; r8_theme() restyles the roles of text, and r8_css() returns the stylesheet of the html classes mode (html_style).
  • R Markdown and Quarto documents, Jupyter notebooks, and tibble columns show R8 values through methods for knitr, repr, and pillar, registered when those packages load.
  • A declaration takes time proportional to itself, whatever the size of its namespace: a package of 200 types loads in 0.03 s.
  • A trait method’s generic finds its impl through a compiled lookup and a cache of selected impls: dispatch on a value takes about 0.33 µs, against 0.41 µs for R6 and S3 in the same measurement.
  • R8 builds on R 4.3 and 4.4: the constructor’s frame routine reads its fields through R’s API of the running version.
  • Declaring a type runs in Rust: the field types, field(), and rule() build and check their arguments in compiled code, and new_struct() and new_enum() read the fields and declare in one call. 200 types declare in 0.028 s, against 0.096 s.
  • The field-type constructors check their arguments at their call: an integer bound or value is a whole number (type_integer(min = 1.5) is an error), and type_character(pattern = ) reports a pattern that does not compile. A reserved field name is an r8_declaration_error with the code name_reserved.
  • A field of an R8 type takes any value of the type as its default, a struct or an enum variant with its fields: field(Kernel, default = Kernel@Rbf(gamma = 0.1)).
  • A rule’s number beyond 2^53, which a double does not hold exactly, is a declaration error (rule_number).
  • rule(invariant, when, message, id): a rule needs neither an ID nor a message, so rule(lo < hi) is a complete rule. A violation of a rule without a message shows its invariant; problems$rule is NA for a rule without an ID, and problems$rule_index gives its position. The old argument order is an error that writes the named form.
  • Validation messages name the field in R syntax and state the requirement and the value found: `w[[2]]` must be at least 0; found -2. [below_min]. They name the nearest allowed value or field, add a hint for a common R mistake (NA, a factor, attributes), count the problems in the header, name the assignment of a $<-, and say when rules were not evaluated because fields are invalid. A sensitive field’s value is withheld from every message, and a long string is cut. problems gains where, suggestion, and hint.
  • list() is the empty map for a hashmap() or ordered_map() field.
  • A package load that fails leaves R8 as it was before, its namespace claims included.
  • variant() refuses fields or rules on a newtype variant (of), and rules on a variant without fields.
  • A name in a declaration follows one grammar in R and in Rust: a reserved word of R or Rust, such as if, is refused, and the message says why.
  • A rule violation in a map or a table names the key, the item, or the cell in R: m[["2"]], om[[2]].
  • In a rule, length() counts the elements of a vector, as in R; nchar() counts a string’s characters. Indexing a field in a rule is an error that names all(), any(), and $.
  • The declaration record has format 2; a package installed with an earlier R8 is reinstalled.
  • val(expr) puts the value of an R expression into a rule as a constant: cost <= val(max_cost). A bare name in a rule is always a field.
  • Rules gain abs(), sum(), nchar(), and min() and max() of one vector. == on a double computed by arithmetic or sum() is a declaration error (rule_float_equality), whose message gives the tolerance form abs(a - b) <= 1e-9.
  • rules = takes a single rule() without list().
  • A violation shows the rule in R and the values it read: scalar fields, the length or dimensions of larger fields, computed operands, and the failing elements .x of an all(). A sensitive field shows as <sensitive>; options(r8.show_values = FALSE) shows no values. The condition’s field problems holds the same data.
  • Rule errors at declaration write the fix: a one-argument all() gives the two-argument form, a name that is not a field names the nearest field and the val() form, an unknown function names the nearest one, and an error shows the R expression at its path.
  • ?rule and the user guide’s chapter “Rules” cover rules on one field and across fields, conditions, vectors, constants, and violations.
  • int64(text) gives an integer beyond 2^53 as its decimal digits, for a rule’s constant or a default; R8 writes such an integer of a declaration in this form, and an integer outside R’s integer range but within 2^53 as a whole double.
  • r8_from_json() reads a document into a compact tree that holds an array of numbers as one run of doubles, then converts it to R or to a Rust-stored value in place. Reading a value with fields of 10^7 elements (99 MB) takes 343 ms and 191 MB beyond the session, against 851 ms and 2.1 GB; a value with fields of 10^6 elements, 31 ms against 183 ms. R8 writes numbers without intermediate strings, and to_json() takes about a third of its time.
  • R8.h: the codec table gains from_reader, which builds a state through an R8Reader, the table of functions over the value R8 has read from a document. Codecs generated by rtemis-r8-api set it, and the member decode is removed; R8 reads a Rust-stored document through from_reader, 10% to 13% faster than a read into R values, and builds a state through from_fields or from_variant for a codec without it. The ABI version stays 1. The exports table gains ir_record, the package’s declarations as a declaration record; tables generated by rtemis-r8-api carry it and set ir_json to NULL, and R8 reads ir_json from tables without it.
  • A type and a trait of one name in a namespace are an error at the later declaration, in either order.
  • r8_register() checks each namespace a package owns once, after its declarations, and refuses a package whose declarations disagree, such as a rule that reads a field of a type declared again without that field.
  • rtemis-r8-api: the method of the R8::PartialOrd trait is cmp, the name of the trait’s method in R; an R8::Dim impl’s Vec<i32> converts to R.
  • The package builds against rtemis-r8 0.4.0.

R8 0.3.0

  • Rust-stored types: a struct whose codec is in a package’s compiled exports keeps its values in compiled code. Field reads return views without copying, x$name <- v replaces a field, and values persist with saveRDS() and cross to mirai and future workers.
  • r8_size() reports the memory a value holds. R8 collects garbage when the memory of Rust-stored values grows.
  • The crate rtemis-r8-api and the macros #[r8::methods] and r8::exports! implement R8 traits and declare Rust-stored types in a package’s Rust code; R8.h gives C and C++ code the same services (R8Api), and a package registers its exports with R_RegisterCCallable().
  • new_struct(native = TRUE) declares a Rust-stored type; r8_document_native() writes the R declarations of the types a package declares in Rust, and r8_register() checks that they match the compiled exports.
  • json_ir() gives a rule or a default as JSON text, for the JSONLogic and defaults that the R forms do not express.
  • Compact sequences, factor codes, and sparse matrix indices are read in place, without expansion, by construction, rules, hashing, validation, equality, and documents.
  • The package builds against rtemis-r8 0.3.0.

R8 0.2.0

  • generic() declares a generic, and implement(generic, Type) <- f declares its method for an R8 type; r8_method() returns a declared method.
  • implement() declares methods of format(), str(), dim(), r8_cmp(), and print() as impls of the standard traits Display, Debug, Dim, PartialOrd, and Print, and methods of other S3 generics as S3 methods for the type’s qualified class.
  • The roxygen2 roclet r8_rd() documents each method of a generic in the generic’s or the type’s Rd file.
  • Struct and enum variant constructors give a required field no default argument.
  • The package builds against rtemis-r8 0.2.0.

R8 0.1.0

  • r8_core_version() returns the version of the rtemis-r8 crate compiled into the package.