Hi, I was wondering if this is expected behavior for active bindings in attached environments, or if this is 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' ? This 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
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"> xfunction() '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
Sorry, I forgot the below:> sessionInfo()R version 2.10.0 Patched (2009-11-05 r50313) i686-pc-linux-gnu locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices datasets utils methods base This also happens on R version 2.11.0 Under development (unstable) (2009-11-05 r50313) Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner [[alternative HTML version deleted]]
Maybe Matching Threads
- Using and 'eval' and environments with active bindings
- parse_Rd raises error when example section contains a quoted percent character
- Surpising behavior when using an active binding as loop index in R 4.0.0
- Surpising behavior when using an active binding as loop index in R 4.0.0
- Creating a reference class object from a class definition in a package fails