Skip to content
Prev 325877 / 398502 Next

Lexical scoping is not what I expect

?f1<- function(x){env<- parent.frame();env$a<-5; g(x)}
f1(2)
#[1] 7
?f1(7)
#[1] 12
?f1(5)
#[1] 10
A.K.

Thread (27 messages)

David Kulp Lexical scoping is not what I expect Jun 24 Rui Barradas Lexical scoping is not what I expect Jun 24 Gabor Grothendieck Lexical scoping is not what I expect Jun 24 arun Lexical scoping is not what I expect Jun 24 Rolf Turner Lexical scoping is not what I expect Jun 24 Marc Schwartz Lexical scoping is not what I expect Jun 24 Duncan Murdoch Lexical scoping is not what I expect Jun 24 David Kulp Lexical scoping is not what I expect Jun 24 William Dunlap Lexical scoping is not what I expect Jun 24 Duncan Murdoch Lexical scoping is not what I expect Jun 25 S Ellison Lexical scoping is not what I expect Jun 26 Duncan Murdoch Lexical scoping is not what I expect Jun 26 Hadley Wickham Lexical scoping is not what I expect Jun 27 S Ellison Lexical scoping is not what I expect Jun 28 Duncan Murdoch Lexical scoping is not what I expect Jun 28 John Fox Lexical scoping is not what I expect Jun 28 Duncan Murdoch Lexical scoping is not what I expect Jun 28 Brian Ripley Lexical scoping is not what I expect Jun 28 John Fox Lexical scoping is not what I expect Jun 28 John Fox Lexical scoping is not what I expect Jun 28 Rolf Turner Lexical scoping is not what I expect Jun 28 Yihui Xie Lexical scoping is not what I expect Jun 28 William Dunlap Lexical scoping is not what I expect Jun 29 Greg Snow Lexical scoping is not what I expect Jun 29 Rolf Turner Lexical scoping is not what I expect Jun 30 Duncan Murdoch Lexical scoping is not what I expect Jun 30 David Winsemius Lexical scoping is not what I expect Jun 30