Skip to content

Question about copying reference objects using the initialize method

3 messages · Aleix Ruiz de Villa, Martin Morgan

#
On 10/31/2011 08:53 AM, Aleix Ruiz de Villa wrote:
Hi Aleix --

 From ?setRefClass

           Initialization methods
           need some care in design, as they do for S4 classes. In
           particular, remember that others may subclass your class and
           pass through field assignments or other arguments.
           Therefore, your method should normally include ... as an
           argument, all other arguments should have defaults or check
           for missingness, and your method should pass all initialized
           values on via '$callSuper()' or '$initFields()' if you know
           that your superclasses have no initialization methods.

so it sounds like your initialize method arguments are expected to have 
default values. My preferred signature would place the '...' first, so 
that unnamed arguments (super-classes) are not unintentionally matched 
to named arguments.

Martin

  
    
1 day later
#
Martin,

thanks. So then I should use options (3) or (4). That's all. Is there
an efficient way to initialize arguments if I have a long list of
arguments? maybe using a 'list'? so that the header of the function is
displayed in a friendly style?

Thanks again!

2011/11/1 Martin Morgan <mtmorgan at fhcrc.org>:
#
On 11/02/2011 08:16 AM, Aleix Ruiz de Villa wrote:
Hi -- I'm not really understanding your question.

Martin