Hi,

The R input/output after the following paragraph is from a session with
version.string R version 2.4.0 Patched (2006-11-23 r39958).

The last element, x$c, of x has no value and after the assignment of x to the
formals of f, x$c does not become a formal argument of f. The second assignment
does the job. It seems that x$c actually becomes the body of f after the first
assignment. There is no problem if the  body of f is not NULL (this probably
explains why the second time the assignment to the formals of f works as
expected.

> x <- alist(a=,b=,c=)
> x$b <- 4
> f <- function(x) NULL
> f
function(x) NULL
> formals(f) <- x
> f
function (a, b = 4)

> formals(f) <- x
> f
function (a, b = 4, c)

> body(f)


-- 
Dr Georgi Boshnakov               tel: (+44) (0)161 306 3684
School of Mathematics             fax: (+44) (0)161 306 3669
The University of Manchester      email: [EMAIL PROTECTED]
Sackville Street
Manchester M60 1QD
UK

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to