Re: [Rd] Ref classes: can I register fields as I register methods?

From: Vitalie S. <spinuvit.list_at_gmail.com>
Date: Sat, 27 Nov 2010 11:58:07 +0100

John Chambers <jmc_at_r-project.org> writes:

> Well, it's an interesting idea, and the current implementation would fit with
> it.
>
> One catch is that it goes against any obvious notion of checking for valid
> objects (admittedly, there are some difficulties in that already with active
> bindings being used).
>
> Another issue is that in normal R programming practice, your "template" class
> would be in a package, in a namespace, and therefore locked. Conceptually at
> least, one would not be allowed to modify that definition.
>
> Both these issues would be solved by using subclasses for the extensions,
> which seems more in the spirit of R. Seems like you could hide the subclass
> details from your users if you wanted to.
>
> So, something to think about, but the use case isn't convincing yet.

Just an user opinion here.

Personally I would like to have separate interfaces for _installation_ and _accessing_ the methods/fields. Something along the following lines.

instFields() and instMethods() would do the installation.

fields() and methods() would get or set the objects with the check for already installed objects. For example:

fields("a","b") will return a list of fields "a" and "b", if those are installed; error otherwise.

fields(a= 32,b= 999) will set the values of "a" and "b", if exists/ error otherwise.

I have already implemented the above in the code required for my work, and found it quite convenient.

Vitalie.
>
> John
>
> On 11/21/10 2:18 PM, Janko Thyson wrote:
>> Hi there,
>>
>>
>>
>> is it possible to register fields as you can register methods with
>> getRefClass("Classname")$methods(.)?
>>
>>
>>
>> I know that you should usually give some thought on which fields you need
>> and hardcode them in the class def. But I'm playing around with dynamically
>> creating/extending sort of a template class that already offers basic
>> functionality shared by all objects that "inherit" from that class. If I
>> follow the usual inheritance paradigm I would have to actually define those
>> new "subclasses" and let them inherit from the superclass (contains
>> argument(, right? But can I get around that by sort of registering new
>> fields? Maybe with 'initFields(.)'?
>>
>>
>>
>> Thanks for any info on that,
>>
>> Janko
>>
>>
>>
>> ##### SYSTEM INFO #####
>>
>> Windows XP SP3
>>
>> R 2.12.0
>>
>> Eclipse 3.6.1 (Helios)
>>
>> StatET 0.9.1
>>
>> #####################
>>
>>
>>
>>
>>
>>
>> [[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 Received on Sat 27 Nov 2010 - 11:07:41 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 28 Nov 2010 - 00:00:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive