[Rd] WishList: Remove Generic Arguments

Michael Lawrence l@wrence@mich@el @ending from gene@com
Thu Aug 9 23:59:26 CEST 2018


A generic function is not simply a way to name two functions (methods)
the same. It has a particular purpose, and the argument names are
aligned with and convey that purpose. The methods only implement
polymorphism; they don't change the purpose. Changing the purpose
would make code unreadable.

Michael

On Thu, Aug 9, 2018 at 2:45 PM, Abs Spurdle <spurdle.a using gmail.com> wrote:
>  I apologize if this issue has been raised before.
>
> I really like object oriented S3 programming.
> However, there's one feature of object oriented S3 programming that I don't
> like.
> Generic functions can have arguments other than dots.
>
> Lets say you have an R package with something like:
>
> print.myfunction (f, ...)
> {   dosomething (f, ...)
> }
>
> Noting that I use function objects a lot.
>
> R CMD check will generate a warning because you've named your object f
> rather than x.
>
> I don't want to name my object x.
> I want to name my object f.
> Naming the object x makes the program unreadable.
> Especially if f contains an attribute or an argument named x.
>
> There's a work around.
> You can redefine the print function, using something like:
>
> print = function (...) base::print (...)
>
> However, you have to export and document the function.
>
> I think that it would be better if generic functions didn't have any
> arguments except for dots.
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



More information about the R-devel mailing list