[R] Use of ellipsis

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Fri May 27 08:24:21 CEST 2022


On Thu, 26 May 2022 15:51:38 -0700
Bert Gunter <bgunter.4567 using gmail.com> wrote:

> FWIW, you don't need to explicitly provide parent.frame() as it's the
> default of the 'envir' argument of eval anyway.

Unfortunately, there's a difference between evaluating parent.frame()
explicitly when calling eval() and letting eval() evaluate
parent.frame() as the default value of the envir argument. What I could
have used here is eval.parent():

x <- 'caller'
f <- function() {
 x <- 'function'
 list(
  eval = eval(quote(x)),
  explicit.parent = eval(quote(x), parent.frame()),
  eval.parent = eval.parent(quote(x))
 )
}
f()
# $eval
# [1] "function"
# 
# $explicit.parent
# [1] "caller"
# 
# $eval.parent
# [1] "caller"

-- 
Best regards,
Ivan



More information about the R-help mailing list