(PR#7495) Function Body / Formals Bug
_________________________________________________________________________= ______________ Note: This e-mail is subject to the disclaimer contained at the bottom of= =20this message. _________________________________________________________________________= ______________ Just a note on the reported bug; it seems to be related to having a NULL function body. # this works
f <- function(a, b) a + b f
function(a, b) a + b
formals(f) <- alist(a=3D, b=3D, c=3D, d=3D) f
function (a, b, c, d)=20 a + b # this also works
f2 <- function(a, b) invisible(NULL) f2
function(a, b) invisible(NULL)
formals(f2) <- alist(a=3D, b=3D, c=3D, d=3D) f2
function (a, b, c, d)=20 invisible(NULL) # this gives a funny result
f3 <- function(a, b) NULL f3
function(a, b) NULL
formals(f3) <- alist(a=3D, b=3D, c=3D, d=3D) f3
function (a, b, c)=20 Note the body of f3 becomes empty in the last example (not even a NULL). This is with R 2.2.0 for Windows.
I'd like to report two bugs in the R function definitions, the first slightly problematic, the second likely unimportant. Both of these are reproducible on both Windows and Linux, R 2.0.1 First Bug:
a <- new("function")
formals(a) <- alist(a=3D, b=3D, c=3D, d=3D)
a
function (a, b, c) ## the d argument disappeared!
formals(a) <- alist(a=3D, b=3D, c=3D, d=3D) a
function (a, b, c, d) ## the d argument reappeared! As you can see from above, the d=3D argument got chopped off completely the first time "formals<-"() is called, but not the second!=20
--=20 Hong Ooi Senior Research Analyst Insurance Australia Group, 388 George St, Sydney NSW 2000 (02) 9292 1566 _________________________________________________________________________= ______________ The information transmitted in this message and its attachments (if any) = is intended=20 only for the person or entity to which it is addressed. The message may contain confidential and/or privileged material. Any revi= ew,=20 retransmission, dissemination or other use of, or taking of any action in= =20reliance=20 upon this information, by persons or entities other than the intended rec= ipient is=20 prohibited. If you have received this in error, please contact the sender and delete = this e-mail=20 and associated material from any computer. The intended recipient of this e-mail may only use, reproduce, disclose o= r distribute=20 the information contained in this e-mail and any attached files, with the= =20permission=20 of the sender. This message has been scanned for viruses with Symantec Scan Engine and c= leared by=20 MailMarshal.