[Rd] Lazy-evaluate elements wrapped with invisible

Dipterix Wang d|pter|x@w@ng @end|ng |rom gm@||@com
Fri Oct 28 22:05:14 CEST 2022


Hi,

I was wondering if it is a good idea to delay the evaluation of expression within invisible(), just like data()/delayedAssign()?

The idea is a function might return an invisible object. This object might not be used by the users if the function returns are not assigned nor passed to another function call. For example,

f <- function() {
  # do something eagerly

  return(invisible({
    # calculate message that might take long/extra memory, but only useful if printed out
  }))
}

If `f()` is not immediately assigned to a variable, then there is no reason to evaluate invisible(…).

This idea is somewhere between `delayedAssign` and eager evaluation. Maybe we could call it delayedInvisible()?

Best,
- Zhengjia



More information about the R-devel mailing list