[R] Object orientation?

Martyn Plummer plummer at iarc.fr
Wed Jan 24 14:38:02 CET 2001


Have you looked at the scoping demo in source directory demos/language?
I think this will show you how to do it.
Martyn

On 24-Jan-01 Yves Gauvreau wrote:
> Hi,
> 
> I wonder how one could implement the following idea in R if it's possible of
> course. Say you have an object, lets call it MyO. I would like MyO to
> provides both properties and methods, encapsulation in OOP terms I think. I
> would like to access MyO properties (only) via functions like {get, let,
> set}.
> 
> For example:
> 
>       MyO.get(PropertyName="default", [Index]); where Index defaults to
current
> item
>       MyO.let(PropertyName="default", Value)
>       MyO.set(PropertyName="default", Value, [Index]); where Index defaults
to a
> new item
> 
> Up to now there is no real problem as I could use the following construct
> for these let and set methods or functions: MyO <-
> MyO.let(PropertyName="ThisProperty", ThisValue).
> 
> But what I would like to be able to do in order to let or set (as above) one
> of MyO properties for example is only use:
> MyO.let(PropertyName="ThisProperty", ThisValue).
> 
> So my question is: Can this be done in a proper and acceptable R fashion?
> 
> I know I could use super assign (<<-) but I think some say it's best
> avoided.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list