r-lib / R6

Encapsulated object-oriented programming for R
https://R6.r-lib.org
Other
407 stars 56 forks source link

Add object copying functionality #57

Closed thomasp85 closed 9 years ago

thomasp85 commented 9 years ago

This commit adds a copy method to all R6 objects It follows the design discussed in #27 . Deep copying is supported through the addition of a deepCopy private method returning a list with a public and/or private element with fields to modify e.g.

...
deepCopy = function() {
  list(
    public = list(
      x=list2env(as.list(self$x))
    )
  )
}
...

See added examples in documentation. Correctness of enclosing environments for both public and private methods as well as active bindings and super methods have been tested, but unit tests are still missing.

thomasp85 commented 9 years ago

BTW sorry for mixing this with #55 - it was unintentional