[Rd] The default behaviour of a missing entry in an environment
Duncan Murdoch
murdoch at stats.uwo.ca
Sat Nov 14 01:55:22 CET 2009
On 13/11/2009 7:26 PM, Gabor Grothendieck wrote:
> On Fri, Nov 13, 2009 at 7:21 PM, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
>> On 13/11/2009 6:39 PM, Gabor Grothendieck wrote:
>>> Note that one should use inherits = FALSE argument on get and exists
>>> to avoid returning objects from the parent, the parent of the parent,
>>> etc.
>> I disagree. Normally you would want to receive those objects. If you
>> didn't, why didn't you set the parent of the environment to emptyenv() when
>> you created it?
>>
>
> $ does not look into the parent so if you are trying to get those
> semantics you must use inherits = FALSE.
Whoops, yes. That's another complaint about $ on environments.
Duncan Murdoch
>
>> x <- 3
>> e <- new.env()
>> "x" %in% names(e)
> [1] FALSE
>> get("x", e) # oops
> [1] 3
More information about the R-devel
mailing list