Skip to content
Prev 37193 / 63424 Next

Creating an environment with attributes in a package

Note that S4 classes extend "environment" and other reference types, by 
using a hidden slot.  You can then add other slots.  So, with some extra 
work:

 > setClass("myEnv", contains = "environment",
+ representation(myName = "character"))
[1] "myEnv"
 > Foo <- new("myEnv", myName = "Foo")
 > Foo
An object of class "myEnv"
<environment: 0x101a3a580>
Slot "myName":
[1] "Foo"

There are a few holes in the implementation as of R 2.11.1, which are 
being filled in r-devel.  Partly to support some new applications for 
extensions of environments, which I hope to commit today (stay tuned to 
this list).
On 7/16/10 5:51 AM, Jon Clayden wrote: