Skip to content

Commit

Permalink
Now globalsByName(names) guarantees the same order as 'names' [#92]
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikBengtsson committed Mar 5, 2024
1 parent 3a75d47 commit be46297
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
@@ -1,5 +1,5 @@
Package: globals
Version: 0.16.2-9003
Version: 0.16.2-9004
Depends:
R (>= 3.1.2)
Imports:
Expand Down
14 changes: 7 additions & 7 deletions R/globalsByName.R
Expand Up @@ -18,9 +18,9 @@
#' If the special argument does not exist, then the value is `NA`, and
#' the corresponding `where` attributes is `NULL`.
#'
#' @return A \link{Globals} object with `length(names)` elements and
#' an attribute `where` with `length(names)` elements.
#' Both of sets of elements are named after `names`.
#' @return A \link{Globals} object of named elements and an attribute
#' `where` with named elements. Both of sets have names according to
#' `names`.
#'
#' @example incl/globalsByName.R
#'
Expand Down Expand Up @@ -53,8 +53,8 @@ globalsByName <- function(names, envir = parent.frame(), mustExist = TRUE,
debug && mdebug("- dotdotdots: <none>")
}

globals <- structure(list(), names = character(0))
where <- structure(list(), names = character(0))
globals <- structure(vector("list", length = nnames), names = namesOrg)
where <- structure(vector("list", length = nnames), names = namesOrg)
for (kk in seq_along(names)) {
name <- names[kk]
debug && mdebug("- locating #%d (%s)", kk, sQuote(name))
Expand All @@ -76,7 +76,6 @@ globalsByName <- function(names, envir = parent.frame(), mustExist = TRUE,
}
}
}
# stop_if_not(identical(names(globals), names))

if (length(dotdotdots) > 0L) {
for (name in dotdotdots) {
Expand All @@ -99,7 +98,8 @@ globalsByName <- function(names, envir = parent.frame(), mustExist = TRUE,
}
stop_if_not(
length(names(globals)) == nnames,
all(names(globals) %in% namesOrg)
all(names(globals) %in% namesOrg),
identical(names(globals), namesOrg)
)

stop_if_not(
Expand Down

0 comments on commit be46297

Please sign in to comment.