Strict variable scoping in R

39 Views Asked by At

I am looking to ensure variables are not pulled from parent environments in R. For instance, I would like to following function to fail.

a <- 1
f <- \() a
f()
# 1

I have tried

local(expr = {
  f()
})

and rlang's locally. Where I would expect this to fail.

They both seem to still pull up from the parent environment

0

There are 0 best solutions below