R/new.R
raw| 1 | |
| 2 | new <- function(expr) { |
| 3 | |
| 4 | private <- new.env(parent = renv_envir_self()) |
| 5 | public <- new.env(parent = private) |
| 6 | |
| 7 | for (expr in as.list(substitute(expr))[-1L]) { |
| 8 | |
| 9 | assigning <- renv_call_matches(expr, names = c("=", "<-")) |
| 10 | if (!assigning) |
| 11 | return(eval(expr, envir = public)) |
| 12 | |
| 13 | hidden <- |
| 14 | is.symbol(expr[[2L]]) && |
| 15 | substring(as.character(expr[[2L]]), 1L, 1L) == "." |
| 16 | |
| 17 | eval(expr, envir = if (hidden) private else public) |
| 18 | |
| 19 | } |
| 20 | |
| 21 | public |
| 22 | |
| 23 | } |