I have some beginner's questions regarding local, in the docs, it says that "local evaluates an expression in a local environment". Q1: why is B different from A? In B, is a<-a+1 getting evaluated before eval proceeds? #A a=0 eval(quote(a<-a+1),new.env()) a # 0 #B a=0 eval(a<-a+1,new.env()) a # 1 Q2: Why does mlocal behave differently? #C local #function (expr, envir = new.env()) #eval.parent(substitute(eval(quote(expr), envir))) #<environment: namespace:base> a=0 local(a<-a+1) a #0 mlocal <- function (expr, envir = new.env()) eval(quote(expr), envir) a=0 mlocal(a<-a+1) a #1 Thank you S