From kmillar at google.com  Thu Dec 12 20:08:18 2013
From: kmillar at google.com (Karl Millar)
Date: Thu, 12 Dec 2013 11:08:18 -0800
Subject: [Rd] Status of reserved keywords and builtins
Message-ID: <CABz6aZeTjummNsA4cKBBf3MiZQLLvjHtnmAkSQJi+LoQ4ZXY8Q@mail.gmail.com>

According to http://cran.r-project.org/doc/manuals/r-release/R-lang.html#Reserved-words

  if else repeat while function for in next break
  TRUE FALSE NULL Inf NaN
  NA NA_integer_ NA_real_ NA_complex_ NA_character_
  ... ..1 ..2 etc.

are all reserved keywords.


However, in R 3.0.2 you can do things like:
   `if` <- function(cond, val1, val2) val2
after which
   if(TRUE) 1 else 2
returns 2.

Similarly, users can change the implementation of `<-`, `(`, `{`, `||` and `&&`.


Two questions:
  - Is this intended behaviour?

  - If so, would it be a good idea to change the language definition
to prevent this?  Doing so would both have the benefits that users
could count on keywords having their normal interpretation, and allow
R implementations to implement these more efficiently, including not
having to lookup the symbol each time.  It'd break any code that
assumes that this is valid, but hopefully there's little or no code
that does.

Thanks

Karl



[Rd] Status of reserved keywords and builtins
Karl Millar