[Rd] Detecting bad lexical scoping

From: Ryan King <c.ryan.king_at_gmail.com>
Date: Wed, 16 Mar 2011 15:14:04 -0500

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.

C Ryan King
Dept Health Studies
University of Chicago

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 17 Mar 2011 - 08:33:39 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 17 Mar 2011 - 13:10:33 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive