[R] Google style

Terry Therneau therneau at mayo.edu
Mon Aug 31 15:36:06 CEST 2009


Since I read digests, and don't read mail on weekends, I come to this
discussion late.  It was very entertaining.  

  I only wish to comment on 2 points.  The first is Henrich's (I
believe) one that trying to convert an old-time user to new styles is
futile.  I agree wholeheartedly.  As proof I offer the survival suite
--anyone who peruses it will notice a different indentation rule for
closing braces.  Why?  It's the style I started with, one that is very
natural to anyone whose first indented language was PL/I.  I may be the
only person in the world who indents R that way, and still I haven't
changed, i.e., even an irrefutable argument may not be enough. 

The second is if-else.  Once the S authors decided not to have a
statement terminator, e.g. the semicolon in C, their fate was sealed:
when in interactive mode the language has to guess wrt to the end of a
statment, and it is impossible to devise a parsing strategy that will
always guess correctly.  In non-interactive mode there is no problem
with if-else since it can read ahead.  That said, for functions I much
prefer "readability" to "write to help out the parser", and put the else
on a separate line.  

But even inside a function it is not always possible to know what the
writer intended:
	zed <- function(x,y,z) {
	       x + y
                 +z
	      }
The authors borrowed so much else from C, the semicolon would have been
good too.




More information about the R-help mailing list