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. 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=) Jim -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Peter wrote: 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 ~~~~~~~~ Bzzt: the bug was in gram.y not in sys.call. It should be fixed now. If an arg list only had one element and that element didn't have a default the arglist was being stripped. I also committed Peter's improved version of formals. All this is in the 0.65 (unstable) branch. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._