From jeffrey.horner at gmail.com  Thu Nov  5 16:53:42 2009
From: jeffrey.horner at gmail.com (Jeffrey Horner)
Date: Thu, 5 Nov 2009 09:53:42 -0600
Subject: [Rd] Active bindings in attached environments
Message-ID: <a8cee7640911050753g7ad9f5fcsd839866cb664af36@mail.gmail.com>

Hi,

Is this expected behavior for active bindings in attached
environments, or is this a bug:

> e <- new.env()
> makeActiveBinding('x',function() 'foo',e)
> ls(e)
[1] "x"
> attach(e)
> search()
[1] ".GlobalEnv"        "e"                 "package:graphics"
[4] "package:grDevices" "package:datasets"  "package:utils"
[7] "package:methods"   "Autoloads"         "package:base"
> x
function() 'foo'

Should this print 'foo' ? The following works as I would expect:

> with(e,x)
[1] "foo"

but this doesn't:

> f <- function() x
> f()
function() 'foo'

However, changing the environment of f does:

> environment(f) <- e
> f()
[1] "foo"


Jeff






-- 
http://biostat.mc.vanderbilt.edu/JeffreyHorner



[Rd] Active bindings in attached environments
Jeffrey Horner