Skip to main content

Module s3_class

Module s3_class 

Source
Expand description

S3 class wrapper generator (structure() + generic.Class dispatch). S3-class R wrapper generator.

Generates lightweight, single-dispatch S3 generics with <generic>.<class> methods. Method dispatch is driven by the class() attribute vector — first match wins — so inheritance is “string-prefix” based and cheap. No formal slot validation, no multi-dispatch (vctrs-style double-dispatch is supported via #[miniextendr(s3(generic = "...", class = "..."))] for vec_ptype2.a.b patterns). Pick S3 for tidyverse interop and for extending existing base generics (print, format, summary); use S4/S7 when you need validation or formal hierarchies.

Re-exports§

use super::ParsedImpl; 🔒

Functions§

class_env 🔒
The class environment of an S3 or vctrs class, Class <- new.env(...) with its roxygen block: @noRd for a class without a page (class_has_no_rd), else on the class’s topic (the impl’s @rdname when it names one, after the topic’s own block, #1900) and exported when the class is (should_export). It holds S3’s Class$new() and the trait namespaces Class$Trait of both systems.
generate_s3_class
Generates the R wrapper of an S3-style class, in the parts the wrapper writer merges per type (super::ClassWrapper, #1776).
no_constructor_head 🔒
The head of an S3 or vctrs class without a constructor: kind is the class system in its title, imports its roxygen imports. Neither gets a new_<class>(): a package that builds its objects in R may write its own (#2069).