From p.dalgaard@biostat.ku.dk  Mon Mar 29 13:13:16 1999
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 29 Mar 1999 14:13:16 +0200
Subject: problems with formals and get (PR#151)
In-Reply-To: jlindsey@alpha.luc.ac.be's message of "Mon, 29 Mar 1999 09:32:11 +0200"
References: <199903290732.JAA28031@blueberry.kubism.ku.dk>
Message-ID: <x2soaomr37.fsf@blueberry.kubism.ku.dk>

jlindsey@alpha.luc.ac.be writes:

> With 0.63.3, try
> 
> test <- function(){
> 	fn <- function(a) print("hello")
> 	print(is.function(fn))
> 	print(names(formals("fn")))}
> test()
> 
> if fn is not quoted in the last line of test, it works properly.

This version of formals seems to work better:

function (fun = sys.function(sys.parent())) 
{
    if (is.character(fun)) 
        fun <- get(fun, mode = "function", envir = sys.frame(sys.parent()))
    .Internal(formals(fun))
}

> test <- function(){
> 	fn <- function() print("hello")
> 	formals(fn) <- alist(a=,b=)
> 	return(fn)}
> formals(test())
> 
> now try with line 3 of test changed to
> 	formals(fn) <- alist(a=)

This is a bug, originating in sys.call:

> xx<-function(...)sys.call()
> xx(a=)
xx()
> xx(a=,b=)
xx(a = , b = )



-- 
   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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


problems with formals and get (PR#151)
Peter Dalgaard BSA