I've a function f() that has some named parameters. It calls a function g() and I want to pass all f's parameters to it. Is this possible?
Using ... just covers the extra arguments:
f=function(a,callback,b,c,d,...){
z=a-b
callback(z,...)
}
g=function(z,...){
print(list(...)) #Only shows $e
print(z) #-1
print(a,b,c,d) #'a' not found
}
f(1,g,2,3,d=4,e=5);
I thought formals() was the answer, but it just seems to be argument names, not their values!
f=function(a,callback,b,c,d,...){
z=a-b
callback(z,formals())
}
g=function(z,...){
args=list(...)[[1]]
print(args$a) #(no output)
print(class(args$a)) #"name"
}
f(1,g,2,3,d=4,e=5);
Is it possible? Thanks.
lm
andglm
to see how this is done. - Hong Ooi