[R] Re: attach()ing User-Defined Classes with Complex Structures
John Chambers
jmc at research.bell-labs.com
Thu Sep 19 22:44:21 CEST 2002
Rob Lee wrote:
>
> How would you implement attach()ing to a user-defined class with multiple
> slots in R?
>
> A primary goal of my software is to hide the data representation from the
> user,
> allowing them to attach() to my program's complex classes and refer to
> their contents by name - THEREBY avoiding having to pass the classes to
> every function call.
>
> Also, is it true that attaching to a to a sub-classed list only get()s you
> access to it's ".Data" slot and nothing else?
>
> -R
This doesn't sound much like the S language.
Data representation is hidden by defining methods for the relevant
functions that behave differently for the different classes in an
application.
You pass objects, not classes, to functions.
And lists don't have slots, they have elements that can be accessed by
name if the list has names. Classes define slots and objects from those
classes have the specified slots.
If, as it sounds, you're trying to override particular names, you might
use R environments that contain the definitions you want. Environments
you can "attach", but not general objects.
If you have some example code, you could send it to me, but preferably
without copying it to all of r-help.
Regards,
John Chambers
--
John M. Chambers jmc at bell-labs.com
Bell Labs, Lucent Technologies office: (908)582-2681
700 Mountain Avenue, Room 2C-282 fax: (908)582-3340
Murray Hill, NJ 07974 web: http://www.cs.bell-labs.com/~jmc
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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