[R] Method for $

Martin Maechler maechler at stat.math.ethz.ch
Fri Nov 18 18:29:27 CET 2005


>>>>> "Ulrike" == Ulrike Grömping <groemping at 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 at slotname, whenever someone calls 
    Ulrike> object$slotname for any object of class "myclass".
    Ulrike> ..............................
    Ulrike> ..............................




More information about the R-help mailing list