[Rd] Bug in the parser (?) (PR#13504)

From: <johnc.deva_at_yahoo.com>
Date: Thu, 05 Feb 2009 14:10:04 +0100 (CET)


Full_Name: John C. Deva
Version: 2.8.1
OS: Fedora Linux 8, 64 bit
Submission from: (NULL) (193.200.150.189)

I notice that it is possible to redefine 'if' as a function of an arbitrary number of arguments. Such redefined 'if' can then be used as any other user function, except for that the parser still demands exactly three arguments to be given to if. Furthermore, even if 'if' is defined with three arguments, its application must still be made with the original syntax, and not the usual syntax of function application:

> `if` <- function(a,b,c)

+ {
+ assign(deparse(substitute(a)), b+c, envir=parent.frame()
+ }

> if (x) 1 else 2
> x

[1] 3

> if(x, 1, 2)

Error: unexpected ',' in "if(x,"

The later expression above should be the only valid when 'if' is redefined as above, but it is not the case.

Sincerely,
John C.



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 05 Feb 2009 - 13:39:52 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 Thu 05 Feb 2009 - 15:30:20 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.

list of date sections of archive