From ggrothendieck at gmail.com  Fri Mar 16 18:54:45 2007
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Fri, 16 Mar 2007 13:54:45 -0400
Subject: [Rd] NextMethod and $.myclass
Message-ID: <971536df0703161054w3ebe6682q1aad4ffc30fe5a99@mail.gmail.com>

The following redefines $ on "myclass" objects so that it looks up
the concatenation of the unevaluated second argument and 2
in the object and returns the result:

"$.myclass" <- function(x, name) x[[paste(substitute(name), 2, sep = "")]]

# test
myobject <- structure(list(x2 = 3), class = "myclass")
myobject$x # 3

The above worked as desired but now I want to rewrite $.myclass so that
it continues to work the same way but uses NextMethod
to get the next $ method where the remaining work is done. The problem
involves the fact that $ does not evaluate name.   Can this still be done
somehow?

"$.myclass" <- function(x, name) {
    modified.name <- paste(substitute(name), 2, sep = "")
    # ???
    NextMethod()
}



[Rd] NextMethod and $.myclass
Gabor Grothendieck