[Rd] Multi-line comments in R

Nathan Esau nesau at sfu.ca
Wed Aug 19 06:16:25 CEST 2015


I was wondering why the decision was made long ago to never implement
multi-line comments in R. I feel there are several argument to be made for
why the R language should have multi-line comments.

1. Many programming languages (including some which are commonly used for
statistics, such as python, matlab and SAS) have this feature.

2. Convenience - some editors may not support commenting out a selected
region of code. This would provide a quick way of commenting and
uncommenting code which could be useful when debugging. Also, if you have
to type a lot of explanatory comments at the top of a code file, it can be
frustrating to have to type "#" at the start of every line in some editors.

I can also think of a few reasons why R doesn't have multi-line comments or
hasn't implemented them so far:

1. Introducing a new multi-line comment delimiter, such as /* */ could
destroy existing code.

2. S didn't implement this feature (as far as I am aware), and R is heavily
influenced by the design of the S language. Also, perhaps the community
doesn't want this feature, and R is a community driven project.

3. Perhaps this would be difficult to implement depending on the way that R
parses source files. Is it even possible to make /* */ or a different
delimiter do something like ``if(FALSE) { }``?

Nathan

	[[alternative HTML version deleted]]



More information about the R-devel mailing list