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

Deprecate isFALSE() #67

Merged
merged 14 commits into from
Jan 31, 2023
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
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Suggests:
rstudioapi,
tinytex (>= 0.30),
mime,
markdown,
knitr,
markdown (>= 1.5),
knitr (>= 1.42),
htmltools,
remotes,
pak,
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

- Added a function `is_arm64()` to test the CPU type (thanks, @AlbanSagouis, #72).

- Started deprecating `xfun::isFALSE()` in favor of `base::isFALSE()` for R >= 3.5.0 (thanks, @mmaechler, #66); `isFALSE()` will eventually be removed from **xfun** when we do not need to support R < 3.5.0.

# CHANGES IN xfun VERSION 0.36

- Added a new argument `resolve_symlink` to `normalize_path()` to get the absolute paths of symlinks without resolving them (with `resolve_symlink = FALSE`).
Expand Down
4 changes: 2 additions & 2 deletions R/packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pkg_attach = function(
suppressPackageStartupMessages(base::library(...))
}
for (i in c(...)) {
if (!isFALSE(install) && !loadable(i)) pkg_install(i, install)
if (!base::isFALSE(install) && !loadable(i)) pkg_install(i, install)
library(i, character.only = TRUE)
}
}
Expand All @@ -60,7 +60,7 @@ pkg_load = function(..., error = TRUE, install = FALSE) {
if (n == 0) return(invisible(res))
for (i in seq_len(n)) {
res[i] = loadable(p <- pkg[i])
if (!isFALSE(install) && !res[i]) {
if (!base::isFALSE(install) && !res[i]) {
pkg_install(p, install); res[i] = loadable(p)
}
}
Expand Down
2 changes: 1 addition & 1 deletion R/paths.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ existing_files = function(x, first = FALSE, error = TRUE) {
x = x[file_exists(x)]
if (!first) return(x)
x = head(x, 1)
if (length(x) != 1 && !isFALSE(error)) {
if (length(x) != 1 && !base::isFALSE(error)) {
if (isTRUE(error)) error = 'None of the specified files exist.'
stop(error, call. = FALSE)
}
Expand Down
2 changes: 1 addition & 1 deletion R/session.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ do_once = function(task, option, hint = c(
'If you never want to see this message,',
sprintf('you may set options(%s = FALSE) in your .Rprofile.', option)
)) {
if (isFALSE(getOption(option))) return(invisible())
if (base::isFALSE(getOption(option))) return(invisible())
task
hint = paste(hint, collapse = ' ')
if (hint != '') message(hint)
Expand Down
22 changes: 18 additions & 4 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,31 @@ in_dir = function(dir, expr) {
expr
}

#' Test if an object is identical to \code{FALSE}
#' Test if an object is \code{FALSE}
#'
#' A simple abbreviation of \code{identical(x, FALSE)}.
#' For R versions lower than 3.5.0, this function is a simple abbreviation of
#' \code{identical(x, FALSE)}. For higher R versions, this function calls
#' \code{base::isFALSE()}.
#' @param x An R object.
#' @note This function will be deprecated in the future. We recommend that you
#' use \code{base::\link[base]{isFALSE}()} instead. If you have to support R
#' versions lower than 3.5.0, you may use \code{identical(x, FALSE)}, but
#' please note that it is not equivalent to \code{base::isFALSE()}.
#' @export
#' @examples
#' @keywords internal
#' @examplesIf getRversion() < '3.5.0'
#' library(xfun)
#' isFALSE(TRUE) # false
#' isFALSE(FALSE) # true
#' isFALSE(c(FALSE, FALSE)) # false
isFALSE = function(x) identical(x, FALSE)
isFALSE = function(x) {
if (!('isFALSE' %in% ls(baseenv()))) return(identical(x, FALSE))
do_once((if (is_R_CMD_check()) stop else warning)(
'The function xfun::isFALSE() will be deprecated in the future. Please ',
'consider using base::isFALSE(x) or identical(x, FALSE) instead.'
), 'xfun.isFALSE.message', '')
base::isFALSE(x)
}

#' Parse R code and do not keep the source
#'
Expand Down
16 changes: 13 additions & 3 deletions man/isFALSE.Rd

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