Skip to content
Prev 170426 / 398503 Next

Distinguishing variables from functions with the same name

Stavros Macrakis wrote:
don't know if it really is advisable, but you can imagine a scenario
where you have different-moded like-named variables within nested
scopes, e.g.:

x = TRUE
local({
    x = 0;
    local({
       x = 'foo';
       list(get('x'), get('x', mode='numeric'), get('x',
mode='logical')) }) })
# list('foo', 0, TRUE)

basically, you want, within a scope, the value of a variable named 'x'
from in the closest environment in which it has the given type of value.

vQ