Skip to content
Prev 33424 / 63424 Next

RFC: methods() and showMethods() {was "debug"}

Martin Maechler <maechler at stat.math.ethz.ch> writes:
Hi Martin --

A couple of thoughts on showMethods and methods, as a preamble.

1. It would be great if showMethods() returned an S4 object so that its
output could be used in a programmatic way.

2. If I

  library(Biobase); library(Matrix)
  showMethods(class="sparseMatrix")

I end up with entries like

  Function "selectSomeIndex":
    <not a generic function>
 
where selectSomeIndex is an unexported generic from Biobase. So it
would be helpful to clarify the output here, probably restricting
methods to those visible to the caller of showMethods.

3. showMethods allows the user to restrict the search to generics
defined in a particular name space, which can be useful.

4. showMethods has an includeDefs argument, which can also be useful
as a shortcut to constructing a second call (to getMethod or
selectMethod) with a potentially complicated argument list to specify
exactly the method to get.

5. methods() reports that 'Non-visible functions are asterisked' but
might provide additional information on how to access these
non-visible functions (e.g., getAnywhere, though here name spaces
might become important).

6. methods(print, "tukeyline") returning all print methods, but not
residuals.tukeyline. I think the behavior one wants is like
showMethods, the intersection of print methods relevant to class
tukeyline.

In terms of the original prompt about methods() functionality, it
would seem that looking for S4 methods, regardless of an ANY-method
would be 'good' since one use case is to understand object
dispatch. Point 1 makes us want to have an object to manipulate, and
then we must decide between S3 and S4 representation, and S4 probably
wins because of the greater flexibility. This might not be palatable to
all, perhaps leading to a smarter methods returning an S3 object and a
smarter showMethods returning an S4 object.

I wonder whether the functionality typically desired by users of
methods() is more analogous to selectMethod, i.e., find and display
the method that my object will be dispatched to, which is related to
4 and 6, above.

Martin

  
    
Message-ID: <6phvdlanmf2.fsf@gopher4.fhcrc.org>
In-Reply-To: <19056.6252.321949.632481@lynne.math.ethz.ch> (Martin Maechler's message of "Wed, 29 Jul 2009 11:37:48 +0200")