[R] How to comment in R

Duncan Murdoch murdoch at stats.uwo.ca
Wed Feb 11 19:45:30 CET 2009

On 2/11/2009 1:21 PM, Stavros Macrakis wrote:
> On Wed, Feb 11, 2009 at 12:32 PM, Greg Snow <Greg.Snow at imail.org> wrote:
>> ...The c-style of /* */ allows both types and you can comment out part of a line, but it is not simple to match and has its own restrictions.  Friedl in his regular expressions book takes 10 pages to develop a pattern to match these (and the final pattern is almost 2 full lines of text in the book).  And this is without allowing nesting....
> Though there is a real debate about the value of multiline, possibly
> nested, comments, the regular expression argument is a red herring.
> Lexical analysis of multiline comments is a solved problem (and not a
> particularly difficult one!), and matters only to language and editor
> implementors.  Emacs handles them with no problem.

I agree about that.  I think the lack of multiline comments comes from 
design considerations rather than implementation ones.   They're just 
not needed, and having two types of comments would lead to weird 
interactions, e.g. is the block comment closed in the lines below?

#  */

Duncan Murdoch

>            -s
> PS And to give credit where credit is due (important on this mailing
> list), the /* */ syntax was defined by PL/I; C simply implemented an
> existing convention and popularized it. :-)
> ______________________________________________
> R-help at 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.

More information about the R-help mailing list