[Rd] Plans to improve reference classes?
h.wickham at gmail.com
Tue Jun 23 17:06:17 CEST 2015
> 1) Is there any example or writeup on the difficulties of extending
> reference classes across packages? Just so I can fully understand the
Here's a simple example:
MyRange <- setRefClass("MyRange", contains = "DiscreteRange")
a_range <- MyRange()
# Error in a_range$train(1:10) : could not find function "train_discrete"
where train_discrete() is an non-exported function of the scales
package called by the train() method of DiscreteRange.
There are also some notes about portable vs. non-portable R6 classes
> 2) In what sorts of situations does the performance of reference
> classes cause problems? Sure, it's an order of magnitude slower than
> constructing a simple environment, but those timings are in
> microseconds, so one would need a thousand objects before it started
> to be noticeable. Some motivating use cases would help.
It's a bit of a pathological case, but the switch from RefClasses to
R6 made a noticeable performance improvement in shiny. It's hard to
quantify the impact on an app, but the impact on the underlying
reactive implementation was quite profound: http://rpubs.com/wch/27260
R6 also includes a vignette with detailed benchmarking:
I've added Winston to the thread since he's the expert.
More information about the R-devel