[Rd] Creating functions programmatically

Hadley Wickham h.wickham at gmail.com
Wed Oct 3 16:47:12 CEST 2012


> There is:  it is `function`.  The parser converts your function definitions
> into a call to it.  (It has 3 arguments: the formals, the body, and the
> srcref.  The environment is added when it is evaluated.)
>
> So your make_function below is pretty similar (but because `function` is
> primitive, some of the evaluation rules might be different).

Hmm, I thought I had it working, but now I can't figure out the
arguments to `function`:

> `function`(NULL,NULL)
function ()
NULL

> `function`(alist(a = 1), NULL)
Error: invalid formal argument list for "function"

I'm obviously missing something dumb.

Thanks!

Hadley

-- 
RStudio / Rice University
http://had.co.nz/



More information about the R-devel mailing list