Hi, Thomas:

(see inline)

Thomas Lumley wrote:

On Thu, 11 Mar 2004, Liaw, Andy wrote:



Gabor,



From: Gabor Grothendieck

Note that R and S are fundamentally different when it comes to
scoping.

R uses lexical scoping, i.e. the parent environment of a function
is the environment at the point where it is *defined* whereas
S uses dynamic scoping, i.e. the parent environment in a function
is the environment at the point where the function is *called*.


I don't think that's quite right. S does not use dynamic scope. This
simple example fails in S-PLUS (6.1):



I'm not sure if there is standard jargon for the scoping rules that S uses, but it certainly isn't dynamic scope. The scope of a name does not change: it's always the local frame plus the global workspace, so we have static scope.

One way to describe the difference between S and R scoping is that in S
environment(fun) would always be the global workspace (frame 0), which is
why the environment() function isn't needed in S.

As a final note, it is "obvious" that dynamic scope is useful and easy to
implement, so people often try to fake it. Lisp developers also used to
think that dynamic scope was more useful and easier than dynamic scope.
They don't now.

Do you mean, "Lisp developers used to think that dynamic scope was ... easier than static scope" or "... static scope was ... easier than dynamic scope"?

Thanks for the clarification. Spencer Graves



-thomas

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html



______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to