Dear R users!

Several languages like C# or VB allow one to create properties; typically
these are under 'get', 'set' tags. My question is this really, what are
similar or comparable strategies in R, and what might be preferred? I have a
couple of situations where I want a certain computation to belong to a
class, but I do not really want to seperate it out to a stand-alone
function.

Here are a couple of options I see possible in R, and if I use the last
described option (see option C below), is there a way to access the object
with something like in C# or C++ where one would probably use the 'this'
keyword or the 'me' keyword in VB from within the property?:

A) [EMAIL PROTECTED] is static and must be handled carefully if it depends
on other slots of the class. If one of the slots changes, then because this
slot is static (containing only the value), it will not change to reflect
the update.

B) [EMAIL PROTECTED] is deprecated, and special accessor functions are used.
The bio group seems to favor this option. So one would use:
Property(MyObject). The drawback I see with this is that there is no strong
relationship between Property and MyObject; they are not explicitly related
via a class structure, and in some way this defeats the point of class
structures.

C) Let [EMAIL PROTECTED] be a function, so in order to fetch the slot object
we would use [EMAIL PROTECTED](); the question here is can I use something
like a 'this' keyword to access other slots of thr object without having to
pass the whole class as a parameter to this slot function, ie the
round-about, clumsy way would have to look like [EMAIL PROTECTED](MyObject).
Ideally, the pseudo-code I have in mind might look like this for an object
with two slots (A and B)

[EMAIL PROTECTED] = function() return([EMAIL PROTECTED])


Thoughts and considerations would be very interesting.

-Tariq

        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to