setConstructorS3            package:R.oo            R Documentation

_D_e_f_i_n_e_s _a _c_l_a_s_s _i_n _S_3/_U_s_e_M_e_t_h_o_d _s_t_y_l_e

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

     Defines a class in R.oo/S3 style. The class name is validated so
     it starts with a letter (A-Z) and it also gives a 'warning' if its
     first letter is _not_ captial. The reason for this is to enforce a
     naming convention that names classes with upper-case initial
     letters and methods with lower-case initial letters (this is also
     the case in for instance Java).

     What this function currently does is simply creating a constructor
     function for the class.

     _Note: The constructor must be able to be called with no
     arguments, i.e. use default values for all arguments or make sure
     you use 'missing()' or similar!_ For instance the following
     defintion is _not_ correct: 'setConstructorS3("Foo", function(x)
     extend(Object(), "Foo", x=x))' whereas this one is
     'setConstructorS3("Foo", function(x=NA) extend(Object(), "Foo",
     x=x))'

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

     ## Default S3 method:
     setConstructorS3(name, definition, private=FALSE, protected=FALSE, static=FALSE, abstract=FALSE, trial=FALSE, deprecated=FALSE, envir=parent.frame(), enforceRCC=TRUE, ...)

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

    name: The name of the class.

definition: The constructor defintion. _Note: The constructor must be
          able to be called with no arguments, i.e. use default values
          for all arguments or make sure you use 'missing()' or
          similar!_

  static: If 'TRUE' this class is defined to be static, otherwise not.
          Currently this has no effect expect as an indicator.

abstract: If 'TRUE' this class is defined to be abstract, otherwise
          not. Currently this has no effect expect as an indicator.

 private: If 'TRUE' this class is defined to be private.

protected: If 'TRUE' this class is defined to be protected.

   trial: If 'TRUE' this class is defined to be a trial class,
          otherwise not. A trial class is a class that is introduced to
          be tried out and it might be modified, replaced or even
          removed in a future release. Some people prefer to call trial
          versions, beta version. Currently this has no effect expect
          as an indicator.

deprecated: If 'TRUE' this class is defined to be deprecated, otherwise
          not. Currently this has no effect expect as an indicator.

   envir: The environment for where the class (constructor function)
          should be stored.

enforceRCC: If 'TRUE', only class names following the R Coding
          Convention is accepted. If the RCC is violated an
          RccViolationException is thrown.

     ...: Not used.


     Note: If a constructor is not declared to be private nor
     protected, it will be declared to be public.

_A_u_t_h_o_r(_s):

     Henrik Bengtsson (<URL: http://www.braju.com/R/>)

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

     To define a method see 'setMethodS3'(). For information about the
     R Coding Conventions, see 'RccViolationException'. For a thorough
     example of how to use this method see 'Object'.

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

     ## Not run: For a complete example see help(Object).

