Skip to content

Is isS3stdGeneric() the right way to detect S3 generics? #846

@jonkeane

Description

@jonkeane

When checking if a function is an S3 generic (after getting it from the NAMESPACE file for example), a call to isS3stdGeneric() is used to tell if the function is an S3 generic. This works well for standard generics (when the first expression in the body calls UseMethod() [1]), but doesn't work so well if there is any sort of pre-processing in the generic (e.g.vctrs::vec_ptype_full which runs some dots checking before calling UseMethod)

> isS3stdGeneric(vctrs::vec_ptype_full)
[1] FALSE

I've looked a bit and haven't yet found a function that will find both standard and non-standard S3 generics. Would it be better / ok to fall back to the prior check of is.function(fun)? Or have an option to do that?

[1] - https://stat.ethz.ch/R-manual/R-devel/library/utils/html/isS3stdGen.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions