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 <maechler@stat.math.ethz.ch> 
To: "Ulrike GrБЎmping" <groemp@tfh-berlin.de> 
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 <groemping@tfh-berlin.de> 
> >>>>> Ба Ба 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 object@slotname, whenever someone calls 
> Ба БаUlrike> object$slotname for any object of class "myclass". 
> Ба БаUlrike> .............................. 
> Ба БаUlrike> .............................. 
------- End of Original Message -------

 

	[[alternative HTML version deleted]]


