title: parLapply within R6 classes
body: <p>I'm looking to use <code>parLapply()</code> on windows within an <code>R6</code> object and noticed (that in at least some cases) that I do not need to export the R6 functions or data to the nodes. </p>
  
  <p>Here is an example where I can access private methods within <code>parLapply()</code>:</p>
  
  <pre><code>require(R6);require(parallel)
  square &lt;-
  R6Class("square",
          public = list(
              numbers = NA,
              squares = NA,
              initialize = function(numbers,integer) {
                  self$numbers &lt;- numbers
                  squares &lt;- private$square.numbers()
              }
          ),
          private = list(
              square = function(x) {
                  return(x^2)
              },
              square.numbers = function() {
                  cl &lt;- makeCluster(detectCores())
                  self$squares &lt;- parLapply(cl,
                                            self$numbers,
                                            function (x) private$square(x)
                                            )
                  stopCluster(cl)
              }
          ))
  ##Test
  test &lt;- square$new(list(1,2,3))
  print(test$squares)
  # [[1]]
  # [1] 1
  # 
  # [[2]]
  # [1] 4
  # 
  # [[3]]
  # [1] 9
  </code></pre>
  
  <p>And a second example where I can also access public members:</p>
  
  <pre><code>square2 &lt;-
  R6Class("square2",
          public = list(
              numbers = NA,
              squares = NA,
              integer = NA,
              initialize = function(numbers,integer) {
                  self$numbers &lt;- numbers
                  self$integer &lt;- integer
                  squares &lt;- private$square.numbers()
              }
          ),
          private = list(
              square = function(x) {
                  return(x^2)
              },
              square.numbers = function() {
                  cl &lt;- makeCluster(detectCores())
                  self$squares &lt;- parLapply(cl,
                                            self$numbers,
                                            function (x) private$square(x)+self$integer
                                            )
                  stopCluster(cl)
              }
          ))
  ##Test
  test2 &lt;- square2$new(list(1,2,3),2)
  print(test2$squares)
  #[[1]]
  #[1] 3
  #
  #[[2]]
  #[1] 6
  #
  #[[3]]
  #[1] 11
  </code></pre>
  
  <p>My question is twofold: (1) What about R6 makes this possible so that I don't need to export data objects and functions; and (2) can I rely on this behavior or is this an artifact of these specific examples?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>This behavior also appears to work using public methods and members after the object has been instantiated:</p>
  
  <pre><code>square3 &lt;- R6Class(
      classname = "square3",
      public = list(
          numbers = NA,
          squares = NA,
          integer = NA,
          square = function(x) {
             return(x^2)
          },
          square.numbers = function() {
              cl &lt;- makeCluster(detectCores())
              self$squares &lt;- parLapply(cl,
                                        self$numbers,
                                     function (x) self$square(x)+self$integer
                                    )
          stopCluster(cl)
      },
      initialize = function(numbers,integer) {
          self$numbers &lt;- numbers
          self$integer &lt;- integer
      }
      )
  )
  test3.obj &lt;- square3$new(list(1,2,3),2)
  test3.obj$square.numbers()
  test3.obj$squares
  
  # [[1]] 
  # [1] 3
  #
  # [[2]]
  # [1] 6
  #
  # [[3]]
  # [1] 11
  </code></pre>