[Rd] slight anomaly in formals<- ? (PR#9758)

From: <georgi.boshnakov_at_manchester.ac.uk>
Date: Tue, 26 Jun 2007 19:15:04 +0200 (CEST)


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: Georgi.Boshnakov_at_manchester.ac.uk
Sackville Street
Manchester M60 1QD
UK

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Tue 26 Jun 2007 - 20:09:15 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 26 Jun 2007 - 20:37:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.