RMethodUtils             package:methods             R Documentation

_R_M_e_t_h_o_d_U_t_i_l_s

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

     Utility functions to support the definition and use of formal
     methods.  Most of these functions will not normally be called
     directly by the user.

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

     makeGeneric(f, fdef, keepMethods=TRUE, useAsDefault=NA,
                 group=character(), valueClass=character())

     makeStandardGeneric(f, fdef)

     generic.skeleton(name, fdef, fdefault)

     defaultDumpName(generic, signature)

     getAllMethods(f, libs=search())

     setAllMethodsSlot(mlist)

     doPrimitiveMethod(name, def, call=sys.call(-1), ev=sys.frame(-2))

     conformMethod(signature, mnames, fnames)

     getGeneric(f, mustFind=FALSE)

     getGroup(fdef, recursive=FALSE)

     getGroupMembers(f, fdef = getGeneric(f))
     setGroupMembers(f, members, fdef = getGeneric(f))

     matchSignature(names, signature, fun)

     ## manage method metadata
     getFromMethodMetaData(name)

     assignToMethodMetaData(name, value)

     removeFromMethodMetaData(name)

     removeMethodsObject(f, where)

     findUnique(what, doFind, message)

     MethodAddCoerce(method, argName, thisClass, methodClass)

     is.primitive(fdef)

     copyEnvironment(object, exceptions)

     cacheMetaData(envir, attach = TRUE)

     cacheGenericsMetaData(generics, attach = TRUE, envir)

     setPrimitiveMethods(f, fdef, code, generic, mlist)

     printNoClass(x, digits, quote, na.print, print.gap, right, ...)

     print.default(x, ...)

     missingArg(symbol, envir = parent.frame())

     balanceMethodsList(mlist, args, check = TRUE)

     sigToEnv(signature)

     rematchDefinition(definition, generic, mnames, fnames)
     unRematchDefinition(definition)

_S_u_m_m_a_r_y _o_f _F_u_n_c_t_i_o_n_s:


     `_m_a_k_e_G_e_n_e_r_i_c': Makes a generic function object corresponding to
          the given function name and optional definition.


     `_m_a_k_e_S_t_a_n_d_a_r_d_G_e_n_e_r_i_c': a utility function that makes a valid
          function calling standardGeneric for name f.  Works (more or
          less) even if the actual definition, fdef, is not a proper
          function, that is, it's a primitive or internal.


     `_c_o_n_f_o_r_m_M_e_t_h_o_d': If the formal arguments, `mnames', are not
          identical to the formal arguments to the function, `fnames',
          `conformMethod' determines whether the signature and the two
          sets of arguments conform, and returns the signature,
          possibly extended.

          The method assignment conforms if either method and function
          have identical formal argument lists.  It can also conform if
          the method omits some of the formal arguments of the function
          but: (1) the non-omitted arguments are a subset of the
          function arguments, appearing in the same order; (2) there
          are no arguments to the method that are not arguments to the
          function; and (3) the omitted formal arguments do not appear
          as explicit classes in the signature.


     `_d_e_f_a_u_l_t_D_u_m_p_N_a_m_e': the default name to be used for dumping a
          method.


     `_g_e_t_A_l_l_M_e_t_h_o_d_s': a generic function (with methods) representing
          the merge of all the versions of `f' on the specified
          packages (anything on the current search path by default).

          If the generic `f' has a group generic, methods for this
          group generic (and further generations of group generics, if
          any) are also merged.

          The merging rule is as follows: each generic is merged across
          packages, and the group generics are then merged, finally
          adding the directly defined methods of `f'.

          The effect of the merging rule is that any method directly
          defined for `f' on any included package overrides a method
          for the same signature defined for the group generic;
          similarly for the group generic and its group, if any, etc.

          For `f' or for a specific group generic, methods override in
          the order of the packages being searched.  A method for a
          particular signature on a particular package overrides any
          methods for the same signature on packages later on in the
          list of packages being searched.

          The slot "allMethods" of the merged methods list is set to a
          copy of the methods slot; this is the slot where inherited
          methods are stored.


     `_d_o_P_r_i_m_i_t_i_v_e_M_e_t_h_o_d': do a primitive call to builtin function
          `name' the definition and call provided, and carried out in
          the environment `ev'.

          A call to `doPrimitiveMethod' is used when the actual method
          is a .Primitive.  (Because primitives don't behave correctly
          as ordinary functions, not having either formal arguments nor
          a function body).


     `_g_e_t_G_e_n_e_r_i_c': return the definition of the function named f as a
          generic.

          If there is no definition in the current search list, throws
          an error or returns NULL according to the value of mustFind.

          Primitive functions are dealt with specially, since there is
          never a formal generic definition for them.  The value
          returned is the formal definition used for assigning methods
          to this primitive. Not all primitives can have methods; if
          this one can't, then `getGeneric' returns `NULL' or throws an
          error.


     `_g_e_t_G_r_o_u_p': return the groups to which this generic belongs.  

          If `recursive=TRUE', also all the group(s) of these groups.


     `_g_e_t_G_r_o_u_p_M_e_m_b_e_r_s', `_s_e_t_G_r_o_u_p_M_e_m_b_e_r_s': Get or set the known members
          of the group generic function `f'.


     `_m_a_t_c_h_S_i_g_n_a_t_u_r_e' Matches the signature object (a partially or
          completely named subset of the arguments of `fun'), and
          return a vector of all the classes in the order specified by
          `names'.  The classes not specified by `signature' will be
          `"ANY"' in the value, but extra trailing `"ANY"''s are
          removed.  When the input signature is empty, the returned
          signature is a single `"ANY"' matching the first formal
          argument (so the returned value is always non-empty).

          The formal arguments of `fun' must agree with `names'
          (usually the formal arguments of the generic function) as
          well, and `matchSignature' checks this.


     `_g_e_t_M_e_t_h_o_d_s_M_e_t_a_D_a_t_a', `_a_s_s_i_g_n_M_e_t_h_o_d_s_M_e_t_a_D_a_t_a', `_m_l_i_s_t_M_e_t_a_N_a_m_e': ut
          ilities to manage methods list objects in a particular
          environment. Not to be called directly.


     `_g_e_t_F_r_o_m_M_e_t_h_o_d_M_e_t_a_D_a_t_a', `_a_s_s_i_g_n_T_o_M_e_t_h_o_d_M_e_t_a_D_a_t_a', `_r_e_m_o_v_e_F_r_o_m_M_e_t_h_o_d_M_e_t_a_D_a_t_a' Funct
          ions to manage the session metadata for methods.  Don't call
          these directly.


     `_M_e_t_h_o_d_A_d_d_C_o_e_r_c_e' Possibly modify one or more methods to
          explicitly coerce this argument to `methodClass', the class
          for which the method is explicitly defined.  Only modifies
          the method if an explicit coerce is required to coerce from
          `thisClass' to `methodClass'.


     `_i_s._p_r_i_m_i_t_i_v_e' Is this object a primitive function (either a
          builtin or special)?


     `_r_e_m_o_v_e_M_e_t_h_o_d_s_O_b_j_e_c_t': remove the metadata object containing
          methods for `f'.


     `_f_i_n_d_U_n_i_q_u_e': Find the first position on the search list
          containing object `what'; if more than one is found, a
          warning message is generated, using `message' to identify
          what was being searched for.

          If `doFind' is supplied, it's the version of `find' used to
          do the search (e.g., `findFunction'.


     `_c_a_c_h_e_M_e_t_a_D_a_t_a', `_c_a_c_h_e_G_e_n_e_r_i_c_s_M_e_t_a_D_a_t_a', `_s_e_t_P_r_i_m_i_t_i_v_e_M_e_t_h_o_d_s': U
          tilities for ensuring that the session-scope information
          about class and method definitions is up to date.  Should
          normally be called automatically whenever needed (for
          example, when a method or class definition changes, or when a
          package is attached or detached.

          The `environment' must be one of the environments on the
          current search list; note in particular that even on
          detaching (`attach=FALSE'), the environment will normally
          still be on the search list.

          The `setPrimitiveMethods' function resets the caching
          information for a particular primitive function.  Don't call
          it directly.


     `_p_r_i_n_t_N_o_C_l_a_s_s',`_p_r_i_n_t._d_e_f_a_u_l_t':  `printNoClass' is equivalent to
          the version of `print.default' in the base package.  The
          methods package overrides the latter function to provide
          meaningful printing for formally defined classes, and
          `printNoClass' is used to get the original default printing.


     `_m_i_s_s_i_n_g_A_r_g':  Returns `TRUE' if the symbol supplied is missing
          from the call corresponding to the environment supplied (by
          default, environment of the call to `missingArg').  If `eval'
          is true, the argument is evaluated to get the name of the
          symbol to test.  Note that `missingArg' is closer to the
          ``blue-book'' sense of the `missing' function, not that of
          the current R base package implementation.  But beware that
          it works reliably only if no assignment has yet been made to
          the argument. (For method dispatch this is fine, because
          computations are done at the begining of the call.)


     `_b_a_l_a_n_c_e_M_e_t_h_o_d_s_L_i_s_t':  Called from `setMethod' to ensure that all
          nodes in the list have the same depth (i.e., the same number
          of levels of arguments).  Balance is needed to ensure that
          all necessary arguments are examined when inherited methods
          are being found and added to the `allMethods' slot.  No
          actual recomputation is needed usually except when a new
          method uses a longer signature than has appeared before.

          Balance requires that all methods be added to the generic via
          `setMethod' (how else could you do it?) or by the initial
          `setGeneric' call converting the ordinary function.


     `_s_i_g_T_o_E_n_v':  Turn the signature (a named vector of classes) into
          an environment with the classes assigned to the names.  The
          environment is then suitable for calling `MethodsListSelect',
          with `evalArgs=FALSE', to select a method corresponding to
          the signature.  Usually not called directly: see
          `selectMethod'.


`._s_a_v_e_I_m_a_g_e': Flag, used in dynamically initializing the methods
     package from `.First.lib'

