Inconsistencies with is.function

Peter Dalgaard BSA p.dalgaard@biostat.ku.dk
01 Mar 1999 15:11:48 +0100


Kjetil Halvorsen <khal@alumni.uv.es> writes:

> > debug("[<-")
> Error in debug("[<-") : argument must be a function
> > is.function(get("[<-"))
> [1] TRUE
> > 
> 
> The problem having to do with .Primitive functions. R should agree
> with itself on what is a function! 

..most likely by fixing the error message in  debug(): "must be a
non-primitive function".

> to work around, I used
> is.Primfun <- function(fun) is.function(fun) && is.null(body(fun))
> 
> but I'm not sure if that is failsafe.

It isn't: 

> is.null(body(function()NULL))
[1] TRUE

However,

> args(function()NULL) 
function () 
NULL
> args(sin)
NULL

so is.null(args(fun)) works better. The construction is also used in
some of the tests/ and demos/ files.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._