"envRefClass"
envRefClass
$
operator. The basic reference class
method for $
needs to make this possible. Essentially, the
operator must return an Rfunction corresponding to the object and
the class method name.Class methods may include an implementation of data abstraction, in
the sense that fields are accessed by "fieldAccessorGenerator"
slot in its definition to a
function of one variable.
This function will be called by setRefClass
with the
vector of field names as arguments.
The generator function must return a list of defined accessor
functions.
An element corresponding to a get operation is invoked with no
arguments and should extract the corresponding field; an element for a
set operation will be invoked with a single argument, the value to be
assigned to the field.
The implementation needs to supply the object, since that is not an
argument in the method invocation.
The mechanism used currently by envRefClass
is described below.
is(x, "refClass")
tests whether x
comes from a class
defined using the reference class mechanism described here;
is(x, "refObject")
tests whether the object has reference
semantics generally, including the previous classes and also classes
inheriting from the Rtypes with reference semantics, such as
"environment"
.Installed class methods are "classMethodDefinition"
objects,
with slots that identify the name of the function as a class method
and the other class methods called from this method.
The latter information is determined heuristically when the class is
defined by using the codetools
recommended package. This
package must be installed when reference classes are defined, but is
not needed in order to use existing reference classes.