Skip to main content

Module s4_class

Module s4_class 

Source
Expand description

S4 class wrapper generator (setClass / setMethod formal OOP). S4-class R wrapper generator.

Generates methods::setClass(...) with an externalptr slot, plus methods::setGeneric / methods::setMethod for each instance method. Supports formal slot validation, multi-dispatch on method signatures, and contains-based inheritance — the only system here with native multi-dispatch. Cost: slowest dispatch path, all helpers live in the methods:: namespace (methods must be imported, not base), and the ecosystem is increasingly legacy. Pick S4 for Bioconductor interop; use S7 for new packages wanting similar formal semantics.

Functions§

generate_s4_class
Generates the R wrapper of an S4-style class, in the parts the wrapper writer merges per type (super::ClassWrapper, #1776).
s4_generic_guard 🔒
The line that defines an S4 instance method’s generic before its setMethod(), shared by the inherent and trait generators.
s4_generic_name 🔒
The S4 generic an instance method dispatches through: an explicit s4(generic = "...") verbatim, else s4_<R method name>, so r_name, postfix and raw identifiers follow the usual naming rules. Shared by the generator and check_s4_generic_collisions, so both agree on the names.