[Rd] Pb with .findInheritedMethods

Herve Pages hpages at fhcrc.org
Fri Oct 27 20:22:08 CEST 2006


Hi John,


John Chambers wrote:
> A problem with callNextMethod, which is caching an inherited method as
> if it was not inherited, causing confusion on the next search.  Should
> be fairly easy to fix, but may be a while before I get time to do so.
>
> By the way, I hope your simplified example does not reflect what
> happens in the actual one.
>    callNextMethod(.Object)
> throws away all the ... arguments to new(), which rather defeats the
> purpose of having initialize() methods.  Generally, callNextMethod()
> should get no arguments or all the arguments it needs, including ...
> See ?callNextMethod

Thanks for looking at this!

Yes it is a simplified version of a real case and
here .Object is all what callNextMethod() needs because
the initialize method for an "A" object takes no argument
other than .Object

More generally I don't see what's wrong with not passing
to callNextMethod all the arguments coming from the call
to new:

    setClass("A", representation(toto="integer"))
    setMethod("initialize", "A", function(.Object, toto0) {.Object at toto
    <- as.integer(toto0); .Object})
    new("A", 45.1)

    setClass("Ab", contains="A")
    setMethod("initialize", "Ab", function(.Object, x, y)
    callNextMethod(.Object, x*y+1))
    new("Ab", 5, 2)


Regards,

H.




More information about the R-devel mailing list