Skip to content
Prev 251656 / 398498 Next

Objects must be passed as an argument or generated in the function, right?

On 24/02/2011 9:59 AM, Jk Zheng wrote:
Functions in R are more properly called "closures".  They are made up of 
code *and an associated environment*.  Normally the environment is the 
one in which the function is created, e.g. the global environment for 
functions entered at the command line, the namespace of a package for 
functions there, or an evaluation frame for a function created within 
another one.

When evaluating a closure, R sets up an evaluation frame with the 
closure's environment as its parent, so any variables defined in the 
environment are also visible.  Presumably "nodes"  was defined in the 
namespace of RpsiXML, but it's possible that parseXmlEntryNodeSet has a 
different environment, depending on how it has been created.  (Or maybe 
it's a typo.)

Duncan Murdoch