MethodsList             package:methods             R Documentation

_M_e_t_h_o_d_s_L_i_s_t _O_b_j_e_c_t_s

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

     These functions create and manipulate 'MethodsList' objects, the
     objects used in R to store methods for dispatch.  You should not
     call any of these functions from code that you want to port to
     S-Plus. Instead, use the functions described in the references.

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

     MethodsList(.ArgName, ...)

     makeMethodsList(object, level=1)

     SignatureMethod(names, signature, definition)

     insertMethod(mlist, signature, args, def, cacheOnly)

     inheritedSubMethodLists(object, thisClass, mlist, ev)

     showMlist(mlist, includeDefs = TRUE, inherited = TRUE,
        classes, useArgNames, printTo = stdout() )

     ## S3 method for class 'MethodsList':
     print(x, ...)

     listFromMlist(mlist, prefix = list())

     linearizeMlist(mlist, inherited = TRUE)

     finalDefaultMethod(mlist, fname = "NULL")

     mergeMethods(m1, m2, genericLabel)

     loadMethod(method, fname, envir)

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

     Note that 'MethodsList' objects represent methods only in the R
     implementation.  You can use them to find or manipulate
     information about methods, but avoid doing so if you want your
     code to port to S-Plus.

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


     '_M_e_t_h_o_d_s_L_i_s_t': Create a MethodsList object out of the arguments.

          Conceptually, this object is a named collection of methods to
          be dispatched when the (first) argument in a function call
          matches the class corresponding to one of the names.  A
          final, unnamed element (i.e., with name '""') corresponds to
          the default method.

          The elements can be either a function, or another
          MethodsList.  In the second case, this list implies
          dispatching on the second argument to the function using that
          list, given a selection of this element on the first
          argument.  Thus, method dispatching on an arbitrary number of
          arguments is defined.

          MethodsList objects are used primarily to dispatch OOP-style
          methods and, in R, to emulate S4-style methods.


     '_S_i_g_n_a_t_u_r_e_M_e_t_h_o_d': construct a MethodsList object containing
          (only) this method, corresponding to the signature; i.e.,
          such that 'signature[[1]]' is the match for the first
          argument, 'signature[[2]]' for the second argument, and so
          on.  The string '"missing"' means a match for a missing
          argument, and '"ANY"' means use this as the default setting
          at this level.

          The first argument is the argument names to be used for
          dispatch corresponding to the signatures.


     '_i_n_s_e_r_t_M_e_t_h_o_d': insert the definition 'def' into the MethodsList
          object, 'mlist', corresponding to the signature.  By default,
          insert it in the slot '"methods"', but 'cacheOnly=TRUE'
          inserts it into the '"allMethods"' slot (used for dispatch
          but not saved).


     '_i_n_h_e_r_i_t_e_d_S_u_b_M_e_t_h_o_d_L_i_s_t_s': Utility function to match the object 
          or the class (if the object is 'NULL') to the elements of a
          methods list. Used in finding inherited methods, and not
          meant to be called directly.


     '_s_h_o_w_M_l_i_s_t': Prints the contents of the MethodsList.  If
          'includeDefs' the signatures and the corresponding
          definitions will be printed; otherwise, only the signatures.


     '_l_i_s_t_F_r_o_m_M_l_i_s_t': Undo the recursive nature of the methods list,
          making a list of function definitions, with the names of the
          list being the corresponding signatures 'prefix' is the
          partial signature (a named list of classes) to be prepended
          to the signatures in this object.

          A utility function used to iterate over all the individual
          methods in the object, it calls itself recursively.


     '_l_i_n_e_a_r_i_z_e_M_l_i_s_t': Undo the recursive nature of the methods list,
          making a list of function definitions, with the names of the
          list being the corresponding signatures.

          Designed for printing; for looping over the methods, use the
          above 'listFromMlist' instead.


     '_f_i_n_a_l_D_e_f_a_u_l_t_M_e_t_h_o_d': The true default method for the methods list
          object 'mlist' (the method that matches class '"ANY"' for as
          many arguments as are used in methods matching for this
          generic function).  If 'mlist' is null, returns the function
          called 'fname', or 'NULL' if there is no such function.


     '_m_e_r_g_e_M_e_t_h_o_d_s': Merges the methods in the second MethodsList
          object into the first, and returns the merged result.  Called
          from 'getAllMethods'.  For a primitive function,
          'genericLabel' is supplied as the name of the generic.


     '_l_o_a_d_M_e_t_h_o_d': Called, if necessary, just before a call to 'method'
          is dispatched in the frame 'envir'.  The function exists so
          that methods can be defined for special classes of objects. 
          Usually the point is to assign or modify information in the
          frame environment to be used evaluation.  For example, the
          standard class 'MethodDefinition' has a method that stores
          the target and defined signatures in the environment.  Class
          'MethodWithNext' has a method taking account of the mechanism
          for storing the method to be used in a call to
          'callNextMethod'.

          Any methods defined for 'loadMethod' must return the function
          definition to be used for this call; typically, this is just
          the 'method' argument.

_R_e_f_e_r_e_n_c_e_s:

     The R package 'methods' implements, with a few exceptions, the
     programming interface for classes and methods in the book
     _Programming with Data_ (John M. Chambers, Springer, 1998), in
     particular sections 1.6, 2.7, 2.8, and chapters 7 and 8.

     While the programming interface for the 'methods' package follows
     the reference, the R software is an original implementation, so
     details in the reference that reflect the S4 implementation may
     appear differently in R.  Also, there are extensions to the
     programming interface developed more recently than the reference. 
     For a discussion of details see '?Methods' and the links from that
     documentation.

