Skip to content
Prev 14146 / 63461 Next

(PR#7320) Internal function isUME() in findGeneric() is

Jeffrey J. Hallman wrote:

            
It's not simply a matter of cleanliness.  Different languages have 
different computing models, which allow different programming 
techniques.  The model underlying R uses ideas from functional 
programming, and in particular the idea that the meaning of a function 
should be as clear as possible from the function itself.  UseMethod() 
clearly tells  you less than UseMethod("coef").

More practically, it's not always clear what "the name of the calling 
function" is, or that such a name has anything to do with the 
computation.  It's the function _as an object_ that should determine 
what happens.  There's nothing in the language that says you shouldn't 
make a vector of function objects, (f[1] <- coef; f[2] <- resid, etc. ) 
and then call (f[i])(myModel).

In S3 methods, the generic function is just a plain "function" object, 
so any convention for hiding "the name" in the object must be somewhat 
of a hack.  In S4, the generic function class could (and does)  have a 
slot in the object to identify the generic, so the issue is less 
obvious.  But one could still argue for using an explicit name when 
dispatching, on the grounds of clarity.