I’m trying to understand what happens at the C level when I call a function in R. For instance, print("Hello, World!")
will call UseMethod("print")
. From the “table” in names.c, line 832, I know that UseMethod()
in turn will call do_usemethod
:
{"UseMethod", do_usemethod, 0, 200, -1, {PP_FUNCALL, PREC_FN, 0}},
I have a basic understanding of what the columns mean, but when I look at the code for do_usemethod
, in objects.c on line 538, I get confused:
/* This is a primitive SPECIALSXP */
attribute_hidden NORET
SEXP do_usemethod(SEXP call, SEXP op, SEXP args, SEXP env)
{
...
}
Can someone explain how and where do_usemethod
picks up the input arguments? I guess op
could be the arity column in names.c, but what about call
, args
and env
? The answer may be obvious, but I find it very difficult to follow the breadcrumbs here, and I have been at it for weeks.
I have read the help for UseMethod()
and also started reading Appendix A of Statistical Models in S (Chambers & Hastie, 1992), but did not find an answer to my question. I don’t know of any books that go more into details.