lexical-scope

How do you use “<<-” (scoping assignment) in R?

邮差的信 提交于 2019-11-25 23:45:45
问题 I just finished reading about scoping in the R intro, and am very curious about the <<- assignment. The manual showed one (very interesting) example for <<- , which I feel I understood. What I am still missing is the context of when this can be useful. So what I would love to read from you are examples (or links to examples) on when the use of <<- can be interesting/useful. What might be the dangers of using it (it looks easy to loose track of), and any tips you might feel like sharing. 回答1:

What is lexical scope?

大城市里の小女人 提交于 2019-11-25 22:23:41
问题 Could someone please give me a brief introduction to lexical scoping? 回答1: I understand them through examples. :) First, Lexical Scope (also called Static Scope), in C-like syntax: void fun() { int x = 5; void fun2() { printf("%d", x); } } Every inner level can access its outer levels. There is another way, called Dynamic Scope used by first implementation of Lisp, again in C-like Syntax: void fun() { printf("%d", x); } void dummy1() { int x = 5; fun(); } void dummy2() { int x = 10; fun(); }