On Wed, Mar 20, 2013 at 12:38 PM, Janko Thyson
<janko.thyson.rst...@googlemail.com> wrote:
> Dear list,
>
> I came across a behavior that IMHO is somewhat undesired when calling
> '$field()':
> If the field name whose value you're trying to get is *not* a valid
> field of the Reference Class, then R doesn't stop there with an error,
> but scans through all enclosing environments/frames. The result is
> something similar to calling '|get(<objname>, inherits=TRUE)|' when
> you'd actually expect something like ' get(<objname>, inherits=FALSE)'
> to be the default (at least I do) in order to avoid undesired retrieval
> results.
>
> Here's a little illustration of the behavior:
> http://stackoverflow.com/questions/15529251/avoiding-consideration-of-enclosing-frames-when-retrieving-field-value-of-a-s4-r

Note that that behavior is documented in ?setRefClass :

$field(name, value)

With one argument, returns the field of the object with character
string name. With two arguments, the corresponding field is assigned
value. Assignment checks that name specifies a valid field, ** but the
single-argument version will attempt to get anything of that name from
the object's environment. **

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

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to