Message-ID: <4995A3AE.5000002@idi.ntnu.no>
Date: 2009-02-13T16:45:34Z
From: Wacek Kusnierczyk
Subject: Distinguishing variables from functions with the same name
In-Reply-To: <8b356f880902130811r1f7d0011i9461f37c6359dc71@mail.gmail.com>
Stavros Macrakis wrote:
> On Fri, Feb 13, 2009 at 10:47 AM, Gabor Grothendieck
> <ggrothendieck at gmail.com> wrote:
>
>> See ?get and try:
>>
>
> Interesting. I hadn't paid attention to the 'mode' argument before.
>
> Where would it be advisable to use anything but mode='any' or mode='function'?
>
>
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