findMethods             package:methods             R Documentation

_D_e_s_c_r_i_p_t_i_o_n_s _o_f _t_h_e _M_e_t_h_o_d_s _D_e_f_i_n_e_d _f_o_r _a _G_e_n_e_r_i_c _F_u_n_c_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     These functions convert the methods defined in a table for a
     generic function (as used for selection of methods) into a list,
     for study or display, or provide other information summarizing the
     methods.

     The function 'findMethods' returns a list of the method
     definitions currently existing for generic function 'f', limited
     to the methods defined in environment 'where' if that argument is
     supplied  and possibly limited to those including one or more of
     the specified 'classes' in the method signature.

     The function 'findMethodSignatures' returns a character matrix
     whose rows are the class names from the signature of the
     corresponding methods; it operates either from a list returned by
     'findMethods', or by computing such a list itself,  given the same
     arguments as 'findMethods' .

     The function 'hasMethods' returns 'TRUE' or 'FALSE' according to
     whether there is a non-empty table of methods for function 'f' in
     the environment or search position 'where' (or anywhere on the
     search list if 'where' is missing).

     The function 'getMethods' is an older alternative to 'findMethods'
     , returning  information in the form of an object of class
     'MethodsList', previously used for method dispatch.  It is not
     recommended, since the object returned is usually less convenient
     than the value of 'findMethods'.

_U_s_a_g_e:

     findMethods(f, where, classes = character(), inherited = FALSE)
     findMethodSignatures(..., target = TRUE, methods = )

     hasMethods(f, where, package)

     getMethods(f, where)

_A_r_g_u_m_e_n_t_s:

       f: A generic function or the character-string name of one.

   where: Optionally, an environment or position on the search list to
          look for methods metadata.

          If 'where' is missing,  'findMethods' uses the current table
          of methods in the generic function itself, and  'hasMethods'
          looks for metadata anywhere in the search list.

 classes: If supplied, only methods whose signatures contain at least
          one of the supplied classes will be included in the value
          returned. 

inherited: Logical flag; if 'TRUE', the table of all methods, inherited
          or defined directly, will be used; otherwise, only the
          methods explicitly defined.  Option 'TRUE' is meaningful only
          if 'where' is missing.

     ...: In the call to 'findMethodSignatures', any arguments that
          might be given to 'findMethods'.

  target: Optional flag to 'findMethodSignatures'; if 'TRUE', the
          signatures used are the target signatures (the classes for
          which the method will be selected); if 'FALSE', they will be
          the signatures are defined.  The difference is only
          meaningful if 'inherited' is 'TRUE'.

 methods: In the call to 'findMethodSignatures', an optional list of
          methods, presumably returned by a previous call to
          'findMethods'.  If missing, that function will be call with
          the ... arguments.

 package: In a call to 'hasMethods', the package name for the generic
          function (e.g., '"base"' for primitives).  If missing this
          will be inferred either from the '"package"' attribute of the
          function name, if any, or from the package slot of the
          generic function.  See details below.

_D_e_t_a_i_l_s:

     The functions obtain a table of the defined methods, either from
     the generic function or from the stored metadata object in the
     environment specified by 'where'.  The information in the table is
     converted as described above to produce the returned value.

     Note that the list returned may contain the primitive function
     itself, when the generic corresponds to a primitive.  (Basically,
     because primitive functions are abnormal R objects, which cannot
     currently be extended as method definitions.)  Computations that
     use the returned list to derive other information need to take
     account of this possibility.  See the implementation of
     'findMethodSignatures' for an example.

     Note that 'hasMethods', but not the other functions, can be used
     even if no generic function of this name is currently found. In
     this case 'package' must either be supplied as an argument or
     included as an attribute of 'f', since the package name is part of
     the identification of the methods tables.

     These functions should be used in searching for or summarizing
     methods, rather than using information about how the metadata for
     methods is stored.

_S_e_e _A_l_s_o:

     'showMethods', 'MethodsList-class'

_E_x_a_m_p_l_e_s:

     mm <-  findMethods("Ops")
     findMethodSignatures(methods = mm)

