[Rd] body(NULL) <- something; ditto formals() -- should not work

Martin Maechler maechler at stat.math.ethz.ch
Mon Mar 7 18:26:25 CET 2016


I'm proposing to signal an error (from R >= 3.3.0) in such
examples -- which do "work" in R 3.2.x and earlier :

> f <- NULL; body(f) <- quote(sin(a+1)); f
function () 
sin(a + 1)
<environment: 0x48f9798>

> g <- NULL; formals(g) <- alist(x = pi, y=); g
function (x = pi, y) 
NULL
<environment: 0x4e6dfe8>
>

The proposal is that the underlying C code will signal an error
when such replacement functions would create a function out of
"something not a function".

Martin Maechler, ETH Zurich



More information about the R-devel mailing list