Skip to content

Should parent.frame() in S7 methods match S3? #596

@t-kalinowski

Description

@t-kalinowski

Spun out from #592.

parent.frame() inside an S7 method currently differs from S3:

library(S7)

foo <- new_generic("foo", "x")
method(foo, class_any) <- function(x) parent.frame()

bar <- function(x) UseMethod("bar")
bar.default <- function(x) parent.frame()

foo(1)
#> <environment: 0x117954580>
bar(1)
#> <environment: R_GlobalEnv>

It would be nice if parent.frame() in an S7 method matched S3 here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions