From jmc at r-project.org  Wed Nov 17 18:00:41 2010
From: jmc at r-project.org (John Chambers)
Date: Wed, 17 Nov 2010 09:00:41 -0800
Subject: [Rd] R5 reference classes: how to initialize exactly?
In-Reply-To: <F69C1FF5-B769-4FAB-9807-7862001C4504@r-project.org>
References: <005b01cb851d$16a21d60$43e65820$@thyson@ku-eichstaett.de>
	<F69C1FF5-B769-4FAB-9807-7862001C4504@r-project.org>
Message-ID: <4CE40A39.6080006@r-project.org>

On the subject of clarification, Reference Classes are not really an 
"addition" to S4.  They are a programming interface to allow OOP (i.e., 
C++ or Java-style) programming in R.

They do use some S4 tools but rely more on some valuable existing 
techniques for dealing with environments, such as active bindings.  They 
use a thin layer on top of existing R with the goal of simpler and 
clearer programming where object references and class-based methods are 
useful.

John

On 11/17/10 2:34 AM, Simon Urbanek wrote:
> Just a clarification for posterity - R5 has nothing to do with the new reference classes. It's not even an official name, but informally it's a collection of ideas for an entirely new object system that can replace both S3 and S4 (not that it will but it should be seen as having the capability to do so technically). Reference classes are just an addition to S4.
>

> Cheers,
> Simon
>
>
> On Nov 16, 2010, at 12:30 AM, Janko Thyson wrote:
>
>> Sorry, I was stupid:
>>
>>
>>
>> MyRefObj<- setRefClass("Blabla", .)
>>
>>
>>
>> One can always get the generator object of an defined class with
>> 'getRefClass()'. So:
>>
>>
>>
>> g<- getRefClass("Blabla")
>>
>> x<- g$new(.)
>>
>>
>>
>> Regards,
>>
>> Janko
>>
>>
>>
>>
>>
>> Von: Janko Thyson [mailto:janko.thyson at ku-eichstaett.de]
>> Gesendet: Dienstag, 16. November 2010 00:27
>> An: 'r-devel at r-project. org'
>> Betreff: R5 reference classes: how to initialize exactly?
>>
>>
>>
>> Dear List,
>>
>>
>>
>> So far, I really like those new R5 classes. But what kind of puzzles me is
>> that it's not just enough to define the actual reference class, I also have
>> to assign it to an object (e.g. 'MyRefObj') in order to fire
>> 'MyRefObj$new(.)'.
>>
>>
>>
>> S4:
>>
>> setClass("Blabla", .)
>>
>> x<- new("Blabla")
>>
>>
>>
>> R5:
>>
>> MyRefObj<- setRefClass("Blabla", .)
>>
>> x<- MyRefObj$new(.)
>>
>>
>>
>> But then how do I define a reference class in a package that should be
>> available after the package is loaded via 'library(my_pkg)' as there is no
>> 'MyRefObj' at startup yet? Do I have to call the script where the definition
>> lives?
>>
>>
>>
>> Thanks for any comments,
>>
>> Janko
>>
>>
>>
>>
>> 	[[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>>
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



[Rd] R5 reference classes: how to initialize exactly?
John Chambers