[R-pkg-devel] Function Overloading of S4 Methods

Dario Strbenac d@tr7320 @end|ng |rom un|@@ydney@edu@@u
Thu May 9 13:00:10 CEST 2019

Good day,

Some programming languages, such as C++, allow function overloading. Is it possible to mimic it when creating S4 methods?

An example from an undergraduate text book is:

int largerInt(int x, int y);
char largerChar(char first, char second);

You can write the previous function prototypes simply as

int larger(int x, int y);
char larger(char first, char second);

Conversely, it does not seen to be possible to use different formal argument names for a S4 generic, unless I don't know about some obscure trick to do it.

Dario Strbenac
University of Sydney
Camperdown NSW 2050

More information about the R-package-devel mailing list