Dear R experts, I looked at the body of, say, `optim' function and found the call to the `.Internal', C optim function. It looks like this: .Internal(optim(par, fn1, gr1, method, con, lower, upper)) On the other hand, the C prototype of optim is: SEXP do_optim(SEXP call, SEXP op, SEXP args, SEXP rho); So, I guess that all the list of parameters passing in R are assigned to `args', right? First, how is that implemented? I looked at the `.Call()' - as I understand, it requires for C-side the same number of parametrs (minus the function name to be called); and `.External()' - it wants the single list. Second, who pass the other, `call', `op' and `rho' parameters to `do_optim() ?' Thank you! -- WBR, Timur
Peter Dalgaard BSA
2003-Jan-17 16:34 UTC
[R] Arguments of R- and C-side of internal functions
Timur Elzhov <Timur.Elzhov at jinr.ru> writes:> Second, who pass the other, `call', `op' and `rho' parameters > to `do_optim() ?'You mean "why" I suppose. op: Some functions are mapped into the same C function (do_math2, for example) so you need to know which one. call: The whole call is passed mainly for the benefit of error printouts. It is not always possible to reconstruct it from the other arguments, since "op" may be computed as in get("+")(2,2). rho: this is the evaluation environment, and it is crucial for variable lookup etc. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907