Skip to content

Review class-system documentation: R5 reference classes count as S4; base objects and S7 classes count as S3 #312

Description

@joethorley

The class checkers (chk_s3_class(), chk_s3_class_strict(), chk_s4_class(), chk_r6_class(), chk_is()) implement two conventions that are only partially documented:

  • R5 (reference) classes count as S4, because isS4() is TRUE for them.
  • Base objects and S7 classes count as S3 for chk_s3_class() (S7 objects are excluded by chk_s3_class_strict()).

These are recorded in a code comment (R/internal.R:21) but are not stated consistently in the user-facing documentation.

Gaps to review:

  • chk_s3_class() documents the base-object / S7 convention but does not mention that R5 reference classes are treated as S4 and so fail the check.
  • chk_s3_class_strict() has no @details note at all, despite excluding S7 objects (via !inherits(x, "S7_object")) as well as R5.
  • chk_s4_class() does not mention that R5 reference classes satisfy the check.
  • vignette("chk-families") describes the S3/S4/R6 checkers without covering either convention, and the formula shown for chk_s3_class() omits the !inherits(x, "R6") term that is in the actual implementation.

Proposed: add a shared @details block (or a documented note reused via @inherit) covering both conventions, apply it across the class checkers, and update the vignette section, including correcting the formulas shown there.

Related to #254.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions