callGeneric             package:methods             R Documentation

_C_a_l_l _t_h_e _C_u_r_r_e_n_t _G_e_n_e_r_i_c _F_u_n_c_t_i_o_n _f_r_o_m _a _M_e_t_h_o_d

_D_e_s_c_r_i_p_t_i_o_n:

     A call to 'callGeneric' can only appear inside a method
     definition.  It then results in a call to the current generic
     function.  The value of that call is the value of 'callGeneric'.
     While it can be called from any method, it is useful and typically
     used in methods for group generic functions.

_U_s_a_g_e:

     callGeneric(...)

_A_r_g_u_m_e_n_t_s:

     ...: Optionally, the arguments to the function in its next call.

          If no arguments are included in the call to 'callGeneric',
          the effect is to call the function with the current
          arguments. See the detailed description for what this really
          means. 

_D_e_t_a_i_l_s:

     The name and package of the current generic function is stored in
     the environment of the method definition object.  This name is
     looked up and the corresponding function called.

     The statement that passing no arguments to 'callGeneric' causes
     the generic  function to be called with the current arguments is
     more precisely as follows.  Arguments that were missing in the
     current call are still missing (remember that '"missing"' is a
     valid class in a method signature).  For a formal argument, say
     'x', that appears in the original call, there is a corresponding
     argument in the generated call equivalent to 'x = x'.  In effect,
     this means that the generic function sees the same actual
     arguments, but arguments are evaluated only once.

     Using 'callGeneric' with no arguments is prone to creating
     infinite recursion, unless one of the arguments in the signature
     has been modified in the current method so that a different method
     is selected.

_V_a_l_u_e:

     The value returned by the new call.

_R_e_f_e_r_e_n_c_e_s:

     Chambers, John M. (2008) _Software for Data Analysis: Programming
     with R_ Springer.  (For the R version.)

     Chambers, John M. (1998) _Programming with Data_ Springer (For the
     original S4 version.)

_S_e_e _A_l_s_o:

     'GroupGenericFunctions' for other information about group generic
     functions; Methods for the general behavior of method dispatch

_E_x_a_m_p_l_e_s:

     ## the method for group generic function Ops
     ## for signature( e1="structure", e2="vector")
     function (e1, e2)
     {
         value <- callGeneric(e1@.Data, e2)
         if (length(value) == length(e1)) {
             e1@.Data <- value
             e1
         }
         else value
     }

     ## For more examples
     ## Not run: 
     showMethods("Ops", includeDefs = TRUE)
     ## End(Not run)

