Skip to content
Prev 3974 / 12125 Next

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

Dear Dario,

I think differently, I think my examples show the resemblance between
the way of "dispatching" for S4 generic and that for C++ overloaded
function.
Both are dispatched ONLY through the type of arguments.

Again following your original example:
int larger(int x, int y);
char larger(char first, char second);
char larger(char x, char y){ # This will work!
if y>x y else x;
}
x = 'a' ; b='b';
larger(x,y);  # this will still call the second function.

The declaration "char largerChar(char first, char second);" does not
make any constraint on the name of argument...

Hope this helps.

Best,
Lei Chen

On Sat, May 18, 2019 at 10:00 AM Dario Strbenac
<dstr7320 at uni.sydney.edu.au> wrote:
Message-ID: <CAPm+3sBkv8DcRru-PN4U8G7-xUhYBWikYUyeSedaK9X-d=7DQQ@mail.gmail.com>
In-Reply-To: <SYBPR01MB39313AC47C0DA886D711134ACD040@SYBPR01MB3931.ausprd01.prod.outlook.com>