Skip to content

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

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.

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