[Rd] Wish there were a "strict mode" for R interpreter. What about You?

From: Paul Johnson <pauljohn32_at_gmail.com>
Date: Sat, 09 Apr 2011 14:51:34 -0500


Years ago, I did lots of Perl programming. Perl will let you be lazy and write functions that refer to undefined variables (like R does), but there is also a strict mode so the interpreter will block anything when a variable is mentioned that has not been defined. I wish there were a strict mode for checking R functions.

Here's why. We have a lot of students writing R functions around here and they run into trouble because they use the same name for things inside and outside of functions. When they call functions that have mistaken or undefined references to names that they use elsewhere, then variables that are in the environment are accidentally used. Know what I mean?

dat <- whatever

someNewFunction <- function(z, w){

   #do something with z and w and create a new "dat"
# but forget to name it "dat"

    lm (y, x, data=dat)
# lm just used wrong data

}

I wish R had a strict mode to return an error in that case. Users don't realize they are getting nonsense because R finds things to fill in for their mistakes.

Is this possible? Does anybody agree it would be good?

-- 
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Sat 09 Apr 2011 - 20:02:41 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 Sat 09 Apr 2011 - 23:10:44 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