-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Escape non-method members with I()
#222
Comments
So this would be up to the user that implements the R6 class, right? I am not sure how R6 would be able to tell the difference. |
Right, I guess in theory escaping non-methods could be done automatically for functions with a class or with a non-local environment. It'd probably be dangerous to introduce this behaviour now though. |
@gabor This could work by having the generator look for functions with the How often do you guys think this comes up? I personally haven't encountered a situation where I've wanted to do this. I have wanted Java-style static classes, though, where methods and values exist on the class itself. That could help cases where functions and values need to be shared among members. For example, it might look something like this: Foo <- R6Class("Foo",
static = list(
x_2 = function() self$x * 2
x = 1
),
public = list(
....
)
)
Foo$x
#> 1
Foo$x_2()
#> 2
# Can still instantiate objects
a <- Foo$new() But I think it might be too late to do that at this point, since it would require changing the internal structure of the generator object, but I suspect there's code out there that depends on the existing internal structure. |
Can the following work?
This is will inadvertently maintain a reference to the generator. Does this mean that every parent of the generator all the way up to global env will get captured when serializing an instance and is hence hazardous, as mentioned in #225 ? |
So these would be equivalent:
Context at r-lib/coro#30.
The text was updated successfully, but these errors were encountered: