-
Notifications
You must be signed in to change notification settings - Fork 991
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
Any modification on a locked binding should fail, even if operated by reference. #778
Comments
Is there a chance to implement this feature soon? It is more R'ish (intuitive) than the reference FR #1086 which also proposes a read-only attribute as a possible alternative... I have gathered all possible references of Stack Overflow questions here: https://stackoverflow.com/questions/44995065/r-how-to-make-a-data-table-read-only-without-copying-it-e-g-for-data-validat |
Another unwanted side effect of the current implementation is, that assigning the
The implementation of this FR should also prevent this side effect. |
I'm not sure it's possible to prevent this. I don't see a way to check whether We need to know e.g. trace(data.table:::`[.data.table`, at=1, quote(message("x's environment: ", format(environment(x)))))
ee$dt[, y := 6:10]
# Tracing `[.data.table`(ee$dt, , `:=`(y, 6:10)) step 1
# x's environment: NULL In this particular case, we can probably back out foo = function() ee$dt
trace(data.table:::`[.data.table`, at=1, quote(message("substitute(x): ", substitute(x))))
foo()[, y := 6:10]
# Tracing `[.data.table`(foo(), , `:=`(y, 6:10)) step 1
# substitute(x): foo Moreover, at the C level, we only have access to Which again requires a It looks like the Lastly, I suspect this will wind up breaking a lot of packages, e.g. if you define a data.table in your package's namespace as some sort of cache, and package functions edit it with Therefore, I am closing this as |
At the moment, even if a binding is locked, it can still be modified by reference:
Relevant SO post.
The text was updated successfully, but these errors were encountered: