by acqq · 11y ago · 0 comments
http://tim-smith.us/arrgh/atomic.html
"This also means that you shouldn't ever assign useful quantities to variables named T and F. Sorry. Other variable names that you cannot use are c, q, t (!), C, D, and I."
Note the contradiction of that limitation and the name of the language. Makes the name even more exceptional.
Is he right? What's with the scope? Can't I introduce a new T in my function thus just hiding the global one from it, but otherwise not disturbing anything? (I don't know R, I'm just asking, reading that the variables have the function scope)
The article is being a little unclear when it says "cannot use". You can use literally any variable name in R if you really want to. If the name you want is already a reserved word (e.g. "for", "else", "function"), or if it is not a syntactically valid token (e.g. '@!":%$>"@;'), then you just have to enclose it in backquotes. So the following is valid R:
`for` <- 1:5
`function` <- 5:1
`TRUE` <- `for` / `function`
`@!":%$>"@;` <- `TRUE`^2
print(`@!":%$>"@;`)temp <- F
F <- T
T <- temp
and if your colleagues are lazy and use T and F (instead of TRUE and FALSE) fun and very gnarly to debug things are going to happen!
Nichts ist wahr! Alles ist erlaubt!