From maechler at stat.math.ethz.ch  Wed Aug 31 09:30:37 2005
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Wed, 31 Aug 2005 09:30:37 +0200
Subject: [Rd] generic function argument list problem
In-Reply-To: <4EC54477-49E9-4F03-8151-5339D493895B@soc.soton.ac.uk>
References: <4EC54477-49E9-4F03-8151-5339D493895B@soc.soton.ac.uk>
Message-ID: <17173.23709.250876.379303@stat.math.ethz.ch>

>>>>> "Robin" == Robin Hankin <r.hankin at noc.soton.ac.uk>
>>>>>     on Wed, 31 Aug 2005 08:09:15 +0100 writes:

    Robin> Hi it says in R-exts that

    1) A method must have all the arguments of the generic,  
       including ... if the generic does.

    2) A method must have arguments in exactly the same order as the generic.

    3) A method should use the same defaults as the generic.


    Robin> So, how come the arguments for rep() are (x, times, ...) and the  
    Robin> arguments
    Robin> for rep.default() are  (x, times, length.out, each, ...) ?  Shouldn't  
    Robin> these be the same?

no.  If they should be the same, the "R-exts" manual would use
a much shorter formulation than the carefully crafted points
1--3 above!

The point is that methods often have  *extra* arguments
which match the "..." of the generic. 
That's one of the points about "..." !

Martin Maechler, ETH Zurich


    Robin> I am writing a rep() method for objects with class "octonion", and
    Robin> my function rep.octonion() has argument list (x, times, length.out,  
    Robin> each, ...)
    Robin> just like rep.default(),   but  R CMD check complains about it, pointing
    Robin> out that rep() and rep.octonion() have different arguments.

    Robin> What do I have to do to my rep.octonion() function to make my package
    Robin> pass R CMD check without warning?


    Robin> --
    Robin> Robin Hankin
    Robin> Uncertainty Analyst
    Robin> National Oceanography Centre, Southampton
    Robin> European Way, Southampton SO14 3ZH, UK
    Robin> tel  023-8059-7743

    Robin> ______________________________________________
    Robin> R-devel at r-project.org mailing list
    Robin> https://stat.ethz.ch/mailman/listinfo/r-devel



    Robin>      A method must have all the arguments of the
    Robin> generic, including ... if the generic does.  A method
    Robin> must have arguments in exactly the same order as the
    Robin> generic.  A method should use the same defaults as
    Robin> the generic.


    Robin> So, how come the arguments for rep() are (x, times,
    Robin> ...) and the arguments for rep.default() are (x,
    Robin> times, length.out, each, ...) ?  Shouldn't these be
    Robin> the same?


    Robin> I am writing a rep() method for objects with class
    Robin> "octonion", and my function rep.octonion() has
    Robin> argument list (x, times, length.out, each, ...)  just
    Robin> like rep.default(), but R CMD check complains about
    Robin> it, pointing out that rep() and rep.octonion() have
    Robin> different arguments.

    Robin> What do I have to do to my rep.octonion() function to
    Robin> make my package pass R CMD check without warning?


    Robin> -- Robin Hankin Uncertainty Analyst National
    Robin> Oceanography Centre, Southampton European Way,
    Robin> Southampton SO14 3ZH, UK tel 023-8059-7743

    Robin> ______________________________________________
    Robin> R-devel at r-project.org mailing list
    Robin> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] generic function argument list problem
Martin Maechler