Why does method inheritance kill additional arguments? Why does method inheritance kill additional arguments? r r

Why does method inheritance kill additional arguments?


As @Roland pointed out, this behavior is documented:

From help("UseMethod") the paragraph about UseMethod() notes (emphasis added):

UseMethod creates a new function call with arguments matched as they came in to the generic. Any local variables defined before the call to UseMethod are retained (unlike S). Any statements after the call to UseMethod will not be evaluated as UseMethod does not return.

The respective paragraph about NextMethod() (already cited above) merely notes:

NextMethod works by creating a special call frame for the next method. If no new arguments are supplied, the arguments will be the same in number, order and name as those to the current method but their values will be promises to evaluate their name in the current method and environment. Any named arguments matched to … are handled specially: they either replace existing arguments of the same name or are appended to the argument list. They are passed on as the promise that was supplied as an argument to the current environment. (S does this differently!) If they have been evaluated in the current (or a previous environment) they remain evaluated. (This is a complex area, and subject to change: see the draft ‘R Language Definition’.)

In short then UseMethod() does something special and extraordinary: it passes on local variables.NextMethod(), as per usual, doesn't do this.

UseMethod() is the exception, not NextMethod().