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.

Functions§

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).