Rob Lee
2002-Sep-18 21:38 UTC
[R] attach()ing User-Defined Classes with Complex Structures
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 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
John Chambers
2002-Sep-19 20:44 UTC
[R] Re: attach()ing User-Defined Classes with Complex Structures
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? > > -RThis 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._