The R Project SVN R

Rev

Rev 66540 | Rev 68626 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 66540 Rev 66564
Line 1... Line 1...
1
% File src/library/methods/man/refClass.Rd
1
% File src/library/methods/man/refClass.Rd
2
% Part of the R package, http://www.R-project.org
2
% Part of the R package, http://www.R-project.org
3
% Copyright 2010-2 R Core Team
3
% Copyright 2010-2014 R Core Team
4
% Distributed under GPL 2 or later
4
% Distributed under GPL 2 or later
5
 
5
 
6
\name{ReferenceClasses}
6
\name{ReferenceClasses}
7
\title{Objects With Fields Treated by Reference (OOP-style)}
7
\title{Objects With Fields Treated by Reference (OOP-style)}
8
\alias{ReferenceClasses}
8
\alias{ReferenceClasses}
Line 71... Line 71...
71
See the section on \dQuote{Implementation} for the internal mechanism
71
See the section on \dQuote{Implementation} for the internal mechanism
72
used by accessor functions.
72
used by accessor functions.
73
 
73
 
74
Note that fields are distinct from
74
Note that fields are distinct from
75
the slots, if any, in the object.  Slots are, as always, handled by
75
the slots, if any, in the object.  Slots are, as always, handled by
76
standard \R{} object management.  
76
standard \R{} object management.
77
It is not generally a good idea to mix slots and fields in the same
77
It is not generally a good idea to mix slots and fields in the same
78
class; this confuses the distinction in behavior between reference
78
class; this confuses the distinction in behavior between reference
79
classes and regular S4 classes.  See the comments in the
79
classes and regular S4 classes.  See the comments in the
80
\dQuote{Implementation} section.
80
\dQuote{Implementation} section.
81
}
81
}
Line 283... Line 283...
283
used to access fields and other methods.
283
used to access fields and other methods.
284
In particular, methods should not use non-exported entries in the
284
In particular, methods should not use non-exported entries in the
285
package's namespace, because the methods may be inherited by a
285
package's namespace, because the methods may be inherited by a
286
reference class in another package.
286
reference class in another package.
287
 
287
 
288
Methods for \code{$initialze()} %$
288
Methods for \code{$initialize()} %$
289
have special requirements.  See the comments in the \dQuote{Value}
289
have special requirements.  See the comments in the \dQuote{Value}
290
section.
290
section.
291
 
291
 
292
Reference methods can not themselves be generic functions; if you want
292
Reference methods can not themselves be generic functions; if you want
293
additional function-based method dispatch, write a separate generic
293
additional function-based method dispatch, write a separate generic
Line 631... Line 631...
631
for any object from the relevant class.
631
for any object from the relevant class.
632
In a method for this class, the field can be accessed by the name
632
In a method for this class, the field can be accessed by the name
633
\code{data}.
633
\code{data}.
634
A field that is not locked can be set by an expression of the form
634
A field that is not locked can be set by an expression of the form
635
\code{x$data <- value}.%$
635
\code{x$data <- value}.%$
636
Inside a method, a field can be assigned by an expresion of the form
636
Inside a method, a field can be assigned by an expression of the form
637
\code{x <<- value}.
637
\code{x <<- value}.
638
Note the \link[=assignOps]{non-local assignment} operator.
638
Note the \link[=assignOps]{non-local assignment} operator.
639
The standard \R interpretation of this operator works to assign it in
639
The standard \R interpretation of this operator works to assign it in
640
the environment of the object.
640
the environment of the object.
641
If the field has an accessor function defined, getting and setting
641
If the field has an accessor function defined, getting and setting