Skip to content
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

Remove new_qenv #222

Merged
merged 5 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export(get_env)
export(get_var)
export(get_warnings)
export(join)
export(new_qenv)
export(qenv)
exportClasses(qenv)
exportMethods(show)
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

### Breaking Change

* `qenv` objects should now be created with `qenv()` rather than `new_qenv()`. The new constructor always creates an empty object. `new_qenv` is now deprecated.
* `qenv` objects should now be created with `qenv()` rather than `new_qenv()` (which has been removed). The new constructor always creates an empty object.

### Miscellaneous

Expand Down
72 changes: 2 additions & 70 deletions R/qenv-constructor.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
#' `qenv()` instantiates a `qenv` with an empty environment.
#' Any changes must be made by evaluating code in it with `eval_code` or `within`, thereby ensuring reproducibility.
#'
#' `new_qenv()` (`r badge("deprecated")` and not recommended)
#' can instantiate a `qenv` object with data in the environment and code registered.
#'
#' @name qenv
#'
#' @return `qenv` and `new_qenv` return a `qenv` object.
#' @return Returns a `qenv` object.
#'
#' @seealso [`base::within()`], [`get_var()`], [`get_env()`], [`get_warnings()`], [`join()`], [`concat()`]
llrs-roche marked this conversation as resolved.
Show resolved Hide resolved
#' @examples
#' # create empty qenv
#' qenv()
Expand All @@ -27,69 +25,3 @@ qenv <- function() {
lockEnvironment(q_env, bindings = TRUE)
methods::new("qenv", env = q_env)
}


#' @param code `r badge("deprecated")`
#' (`character(1)` or `language`) code to evaluate. Accepts and stores comments also.
#' @param env `r badge("deprecated")` (`environment`)
#' Environment being a result of the `code` evaluation.
#'
#' @examples
#' # create qenv with data and code (deprecated)
#' new_qenv(env = list2env(list(a = 1)), code = quote(a <- 1))
#' new_qenv(env = list2env(list(a = 1)), code = parse(text = "a <- 1", keep.source = TRUE))
#' new_qenv(env = list2env(list(a = 1)), code = "a <- 1")
#'
#' @rdname qenv
#' @aliases new_qenv,environment,expression-method
#' @aliases new_qenv,environment,character-method
#' @aliases new_qenv,environment,language-method
#' @aliases new_qenv,environment,missing-method
#' @aliases new_qenv,missing,missing-method
#'
#' @seealso [`base::within()`], [`get_var()`], [`get_env()`], [`get_warnings()`], [`join()`], [`concat()`]
#'
#' @export
setGeneric("new_qenv", function(env = new.env(parent = parent.env(.GlobalEnv)), code = character()) {
lifecycle::deprecate_warn(when = " 0.5.0", what = "new_qenv()", with = "qenv()", always = TRUE)
standardGeneric("new_qenv")
})

setMethod(
"new_qenv",
signature = c(env = "environment", code = "expression"),
function(env, code) {
new_qenv(env, paste(lang2calls(code), collapse = "\n"))
}
)

setMethod(
"new_qenv",
signature = c(env = "environment", code = "character"),
function(env, code) {
new_env <- rlang::env_clone(env, parent = parent.env(.GlobalEnv))
lockEnvironment(new_env, bindings = TRUE)
if (length(code) > 0) code <- paste(code, collapse = "\n")
id <- sample.int(.Machine$integer.max, size = length(code))
methods::new(
"qenv",
env = new_env, code = code, warnings = rep("", length(code)), messages = rep("", length(code)), id = id
)
}
)

setMethod(
"new_qenv",
signature = c(env = "environment", code = "language"),
function(env, code) {
new_qenv(env = env, code = paste(lang2calls(code), collapse = "\n"))
}
)

setMethod(
"new_qenv",
signature = c(code = "missing", env = "missing"),
function(env, code) {
new_qenv(env = env, code = code)
}
)
1 change: 0 additions & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ reference:
- get_var
- get_warnings
- join
- new_qenv
- qenv
- show,qenv-method
- within.qenv
23 changes: 2 additions & 21 deletions man/qenv.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading