I have had that thought myself as well, but don't see any harm in my particular application. I describe in general terms what I'm trying to do: I have defined a class for the output of a function that does various calculations. The reason for this is that I want methods for plotting and printing for the output object. On the other hand, the output object does include various sub-objects the access of which is useful for users (basically, the object was a list of several vectors and numbers, before I decided that I need a class, and in the class definition, I have defined the elements of the list as slots).
Maybe I could (and should?) have defined the class with just one slot that contains the list, which would make it behave like I want it immediately. Regards, Ulrike Grömping ---------- Original Message ----------- From: Martin Maechler <[EMAIL PROTECTED]> To: "Ulrike Grömping" <[EMAIL PROTECTED]> Cc: r-help@stat.math.ethz.ch Sent: Fri, 18 Nov 2005 18:29:27 +0100 Subject: Re: [R] Method for $ > >>>>> "Ulrike" == Ulrike Grömping <[EMAIL PROTECTED]> > >>>>> on Fri, 18 Nov 2005 15:37:58 +0100 writes: > > Ulrike> Dear R experts, > > Ulrike> I have defined a class "myclass" and would like the > Ulrike> slots to be extractable not only by "@" but also by "$". > > hmm, I know this is not what you've asked for, but > why would you want to do that? To me, it seems a pretty harmful idea > that only leads to confusion and does not provide sensible > functionality. > > When S4 classes where created, using '@' instead of '@' with a > *different* meaning was very much on purpose and I think it's a > bit too ambitious to try being smarter than John Chambers, > the creator of the S4 object system, on this. > > Martin Maechler, ETH Zurich > > Ulrike> I now try to write a method for "$" that > Ulrike> simply executes the request [EMAIL PROTECTED], whenever someone > calls > Ulrike> object$slotname for any object of class "myclass". > Ulrike> .............................. > Ulrike> .............................. ------- End of Original Message ------- [[alternative HTML version deleted]]
______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html