2009/8/31 David Scott <d.sc...@auckland.ac.nz> > > > I think this discussion is valuable, and have previously asked about style > which I think is very important. Base R does suffer from very inconsistent > naming and as I think Duncan said it makes it very difficult sometimes to > remember names when you have variations in case and separators as with > things related to system. > > David > > Is it a foolish idea to think that perhaps code could be checked and re-formatted automatically when building a package?
Say, I write a function like this, this.is.my.name = function( a = 1,b=2, # i'm a comment z=F) { if(T) { print("true") } else { print("else") } } package.skeleton automatically converts the first "=" sign to "<-" and sometimes also adds backquotes `` to protect the function name. Could this be extended in a few ways, 1- rationalise the function naming scheme, e.g convert every function name to camelCase (and provide aliases not to break dependencies) 2- indent the code and add spaces around commas 3- tidy up the position of braces to make it consistent 4- convert T and F to TRUE and FALSE, this sort of things 5- finally, run a comparison of the two versions to check that the behaviour is as intended. 1,2,3 could be tuned according to a template that the user chooses for a given package (some may prefer underscores, etc.) Perhaps I'm dreaming a bit here, this sounds like meta-programming. Best, baptiste [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.