Skip to content
Prev 170142 / 398506 Next

How to comment in R

Stavros,

Thanks for the clarification and going further back in the credit for /* */.  

I don't think that the regex argument is a complete red herring (possibly a pink herring or burnt umber herring?).  The post I was responding to said that implementing it would be trivial, I think that the fact that Friedl spends 10 pages discussing it shows that it is less than trivial.  While the parser can process the comments without using regular expressions, some of the issues that Friedl brings up still need to be considered in deciding the rules.  Implementing this in the parser may well be trivial once the rules are decided on (but way beyond me), but I still think that deciding on the rules and documenting them is far from trivial.  

I remember having some C code that compiled fine and did as intended with one compiler, then when I tried compiling with a different compiler it threw an error based on the commenting (probably the difference was in the preprocessors, not the compilers), so the 2 different versions of the C compiler/preprocessor did not even agree on the rules (I don't remember emacs complaining either way).

Others have mentioned using sed as another way to add/strip comment markers to regions of code.  Along these lines someone could always use C-style (or PL/I style to be more correct but less common in my experience) comments, then run the code through a C preprocessor before submitting to R (then you just have to live with the rules of the preprocessor).

I have no problem with someone adding this capability to R, I just prefer that R-Core spends their time on higher priority items.  If someone else wants to contribute the change, I won't complain (unless it breaks my existing code, which is unlikely if done properly), I just wanted anyone who was thinking of doing this to think about some of the potential pitfalls so that if they implement it, they implement it well.

Thread (42 messages)

Mihai.Mirauta at bafin.de How to comment in R Feb 11 Søren Højsgaard How to comment in R Feb 11 Mihai.Mirauta at bafin.de How to comment in R Feb 11 Mihai.Mirauta at bafin.de How to comment in R Feb 11 ONKELINX, Thierry How to comment in R Feb 11 Stephan Kolassa How to comment in R Feb 11 Mihai.Mirauta at bafin.de How to comment in R Feb 11 Søren Højsgaard How to comment in R Feb 11 Mihai.Mirauta at bafin.de How to comment in R Feb 11 ONKELINX, Thierry OPGELET PHISINGRE: How to comment in R Feb 11 Wacek Kusnierczyk How to comment in R Feb 11 Gábor Csárdi How to comment in R Feb 11 (Ted Harding) How to comment in R Feb 11 Bart Joosen How to comment in R Feb 11 Wacek Kusnierczyk How to comment in R Feb 11 Barry Rowlingson How to comment in R Feb 11 Gabor Grothendieck How to comment in R Feb 11 Baptiste Auguie How to comment in R Feb 11 Gustaf Rydevik How to comment in R Feb 11 Baptiste Auguie How to comment in R Feb 11 Greg Snow How to comment in R Feb 11 Stavros Macrakis How to comment in R Feb 11 Duncan Murdoch How to comment in R Feb 11 Greg Snow How to comment in R Feb 11 Wacek Kusnierczyk How to comment in R Feb 11 Wacek Kusnierczyk How to comment in R Feb 11 Wacek Kusnierczyk How to comment in R Feb 11 Wacek Kusnierczyk How to comment in R Feb 11 Duncan Murdoch How to comment in R Feb 11 Gavin Simpson How to comment in R Feb 11 Wacek Kusnierczyk How to comment in R Feb 11 Wacek Kusnierczyk How to comment in R Feb 11 Duncan Murdoch How to comment in R Feb 11 Greg Snow How to comment in R Feb 11 Wacek Kusnierczyk How to comment in R Feb 11 Wacek Kusnierczyk How to comment in R Feb 11 Wacek Kusnierczyk How to comment in R Feb 11 Berwin A Turlach How to comment in R Feb 12 Wacek Kusnierczyk How to comment in R Feb 12 Hufkens Koen rimage Feb 16 Dirk Eddelbuettel rimage Feb 16 Hufkens Koen rimage Feb 16