From jmc at r-project.org  Wed Oct 18 15:31:21 2006
From: jmc at r-project.org (John Chambers)
Date: Wed, 18 Oct 2006 09:31:21 -0400
Subject: [Rd] Caching bug with showMethods?
In-Reply-To: <m2ac3uv954.fsf@ziti.local>
References: <m2ac3uv954.fsf@ziti.local>
Message-ID: <45362CA9.4050803@r-project.org>

No, not a bug.

Inherited methods are never cached until they are needed, for rather 
obvious efficiency reasons. See ?showMethods, under argument inherited=

If what you were trying to do was find out what method would be called 
for class "B" without calling it, use selectMethod().

Seth Falcon wrote:
> showMethods isn't reporting inherited methods when it is first
> called.  The methods are there and after calling them, showMethods
> gives the right output.
>
> Here is an example (using R-devel r39647):
>
> setClass("A", representation(x="numeric"),
>          prototype=list(x=1))
>
> setClass("B", contains="A",
>          prototype=list(x=2))
>
> setMethod("initialize", "A",
>           function(.Object) {
>               cat("In A's init\n")
>               .Object at x <- .Object at x + 1
>               .Object
>           })
>
> setMethod("show", "A",
>           function(object) cat("An A like thing. x =", object at x, "\n"))
>
> showMethods(classes="B")  ## should give output, but doesn't
> showMethods(classes="A")
>
> aa <- new("A")
> bb <- new("B")
>
> aa
> bb
>
> ## Now it will give output
> showMethods(classes="B")
>
>
>
>
> --
> + seth
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>




[Rd] Caching bug with showMethods?
John Chambers