From ggrothendieck at gmail.com  Thu Mar 17 13:47:46 2011
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Thu, 17 Mar 2011 08:47:46 -0400
Subject: [Rd] Detecting bad lexical scoping
In-Reply-To: <AANLkTimpAMDo383a2D85OBg4JOhkxzFpyThT4cvt1-7i@mail.gmail.com>
References: <AANLkTimpAMDo383a2D85OBg4JOhkxzFpyThT4cvt1-7i@mail.gmail.com>
Message-ID: <AANLkTikTdA-ARMcetLivgetF9Gmqdq+fZbFr7igKmus4@mail.gmail.com>

On Wed, Mar 16, 2011 at 4:14 PM, Ryan King <c.ryan.king at gmail.com> wrote:
> I've recently hunted down a troublesome bug in my own code, and am
> looking for an easy mechanism to detect this kind of error in other R
> code. ?The problem was an undefined variable inside of a function.
> Unfortunately, R looked for that variable in the global environment
> and found it since there was variable with that name in my testing
> scripts (note to self: do not name things "x").
>
> Is there an easy way to report all the non-local objects accessed in a
> function?
>
> Is there any easy way around the usual scoping rules? ?I want to be
> able to get to base functions, and am willing to namespace:: or :::
> access all of my own functions (it's in a package) if necessary to
> block the standard scoping rules. ?The language def section on
> environments made me hurt.
>

One way is discussed in the Feb 27, 2010 news item on the proto home
page: http://r-proto.googlecode.com

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



[Rd] Detecting bad lexical scoping
Gabor Grothendieck