Re: [R] static vs. lexical scope

2019-10-20 Thread Francesco Ariis
Hello everyone again, I much appreciated the explanations. On Wed, Sep 25, 2019 at 11:02:42AM +0200, Francesco Ariis wrote: > Maybe the Introduction should link to it (or similar page) with text > "In case you are interest in the difference between static and lexical > scope, check this explan

Re: [R] static vs. lexical scope

2019-09-29 Thread Richard O'Keefe
I didn't say R's rules were "a mystery" or "overly complicated", but that they are "weird". When I started trying to compile R, with() did not exist, if I remember correctly. Half the point of compiling is to do variable lookups at compile time. In an example like function (...) { use x

Re: [R] static vs. lexical scope

2019-09-26 Thread Jeff Newmiller
I found this confusing until I learned about environments. The current state of the environment that was active at the time the function was defined is searched, not a frozen copy of the enclosing environment as it existed at the time the function was defined. x <- 1 # as it was when f was crea

Re: [R] static vs. lexical scope

2019-09-26 Thread Duncan Murdoch
On 26/09/2019 12:14 p.m., William Michels wrote: The best summary I've read on the subject of R's scoping rules (in particular how they compare to scoping rules in S-PLUS) is Dr. John Fox's "Frames, Environments, and Scope in R and S-PLUS", written as an Appendix to the first edition of his book,

Re: [R] static vs. lexical scope

2019-09-26 Thread William Michels via R-help
The best summary I've read on the subject of R's scoping rules (in particular how they compare to scoping rules in S-PLUS) is Dr. John Fox's "Frames, Environments, and Scope in R and S-PLUS", written as an Appendix to the first edition of his book, An R and S-PLUS Companion to Applied Regression (2

Re: [R] static vs. lexical scope

2019-09-26 Thread Duncan Murdoch
On 26/09/2019 9:44 a.m., Richard O'Keefe wrote: Actually, R's scope rules are seriously weird. I set out to write an R compiler, wow, >20 years ago. Figured out how to handle optional and keyword parameters efficiently, figured out a lot of other things, but choked on the scope rules. Consider

Re: [R] static vs. lexical scope

2019-09-26 Thread Richard O'Keefe
Actually, R's scope rules are seriously weird. I set out to write an R compiler, wow, >20 years ago. Figured out how to handle optional and keyword parameters efficiently, figured out a lot of other things, but choked on the scope rules. Consider > x <- 1 > f <- function () { + a <- x + x <- 2

Re: [R] static vs. lexical scope

2019-09-26 Thread Martin Møller Skarbiniks Pedersen
On Wed, 25 Sep 2019 at 11:03, Francesco Ariis wrote: > > Dear R users/developers, > while ploughing through "An Introduction to R" [1], I found the > expression "static scope" (in contraposition to "lexical scope"). > > I was a bit puzzled by the difference (since e.g. Wikipedia conflates the > tw

[R] static vs. lexical scope

2019-09-25 Thread Francesco Ariis
Dear R users/developers, while ploughing through "An Introduction to R" [1], I found the expression "static scope" (in contraposition to "lexical scope"). I was a bit puzzled by the difference (since e.g. Wikipedia conflates the two) until I found this document [2]. Maybe the Introduction should