From jmc at r-project.org  Tue Jun 23 17:11:08 2015
From: jmc at r-project.org (John Chambers)
Date: Tue, 23 Jun 2015 08:11:08 -0700
Subject: [Rd] Plans to improve reference classes?
In-Reply-To: <CABdHhvEu9tb-3p7apMdx2orhsKQZiAbxX+DwhC44E5Xa3rD0Vg@mail.gmail.com>
References: <da993e9e95c744a18958291ae25b898d@CRIUS2013.keygene.local>
	<CAOQ5NycbBMTRQrtoXU=UrX0J4HLX-CONTDndSB=gKn7gV9pJ5w@mail.gmail.com>
	<CABdHhvGQX+6U21P4kKh1XesNa9ivB3xXVPkno0vNtJNr3eQajg@mail.gmail.com>
	<CAOQ5Nyf_6QPNy0nzhrzmgq7Pi14WcksqGB3Oe=21Qv-sPToX+w@mail.gmail.com>
	<CABdHhvEu9tb-3p7apMdx2orhsKQZiAbxX+DwhC44E5Xa3rD0Vg@mail.gmail.com>
Message-ID: <554C587E-FF8E-49A3-81B7-7B3FAEFF8480@r-project.org>

I understand Hadley's point; it's a consequence of the modification of the environment of the ref. class methods.

Good point, but it seems we can make that an option (there are advantages to it of code quality and ease of writing, when it works);

Let's discuss possibilities, off-list until things are a bit clearer.

John

On Jun 23, 2015, at 8:06 AM, Hadley Wickham <h.wickham at gmail.com> wrote:

>> 1) Is there any example or writeup on the difficulties of extending
>> reference classes across packages? Just so I can fully understand the
>> issues.
> 
> Here's a simple example:
> 
> library(scales)
> library(methods)
> 
> MyRange <- setRefClass("MyRange", contains = "DiscreteRange")
> a_range <- MyRange()
> a_range$train(1:10)
> # 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
> at http://cran.r-project.org/web/packages/R6/vignettes/Portable.html
> 
>> 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
> vs  http://rpubs.com/wch/27264
> 
> R6 also includes a vignette with detailed benchmarking:
> http://cran.r-project.org/web/packages/R6/vignettes/Performance.html
> 
> I've added Winston to the thread since he's the expert.
> 
> Hadley
> 
> -- 
> http://had.co.nz/
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Plans to improve reference classes?
John Chambers