Scope modifiers: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 475: | Line 475: | ||
=={{header|R}}== |
=={{header|R}}== |
||
{{incorrect|R|<<- is not a "global assignment" operator. It would also be worth showing R constructs that can emulate dynamic scope, call-by-name, etc.}} |
|||
R uses lexical scoping – there is a nice introduction to this in the [http://cran.r-project.org/doc/FAQ/R-FAQ.html#Lexical-scoping FAQ on R]. There are no keywords related to scoping, but the [http://stat.ethz.ch/R-manual/R-patched/library/base/html/assign.html assign] function allows you to choose the environment in which a variable is assigned. The global assignment operators , '<<-' and '->>' are effectively shorthand for 'assign(..., envir=globalenv()). |
R uses lexical scoping – there is a nice introduction to this in the [http://cran.r-project.org/doc/FAQ/R-FAQ.html#Lexical-scoping FAQ on R]. There are no keywords related to scoping, but the [http://stat.ethz.ch/R-manual/R-patched/library/base/html/assign.html assign] function allows you to choose the environment in which a variable is assigned. The global assignment operators , '<<-' and '->>' are effectively shorthand for 'assign(..., envir=globalenv()). |
||
<lang r>x <- "defined in global env" |
<lang r>x <- "defined in global env" |