[R] Object orientation?

Yves Gauvreau cyg at sympatico.ca
Wed Jan 24 14:11:57 CET 2001


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,

For example:

	MyO.get(PropertyName="default", [Index]); where Index defaults to current
	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

Thanks for your time.

Yves Gauvreau
B.E.F.P. Université du Québec à Montréal
cyg at sympatico.ca

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