Comments - was Re: Include file changes

Peter Dalgaard BSA p.dalgaard@biostat.ku.dk
16 Jun 1999 14:20:37 +0200


Jonathan Rougier <J.C.Rougier@durham.ac.uk> writes:

> >From my reading of the source code I think comments are always going to be
> tricky to locate while they are treated as attributes.  I appreciate that
> this is a feature of the Blue Book description, but I wonder if a simpler
> arrangement might not be possible.  How about if comments were legitimate
> expressions that evaluated to "invisible(.Last.value)", or, for those that
> follow on on the line, "; invisible(.Last.value)".  Of course this would
> slow the function down if implemented as is, but perhaps not if
> implemented in the C code.
> 
> This may be a naive suggestion, and I am certainly not an expert in
> comments, but I do find it frustrating to see all most of my helpful
> asides coming out in the wrong place.  It seems to be Sod's Law that
> comments are most useful after if() statements, when of course they are
> promoted up the function.

I'm afraid that your idea would break on things like

if (blabla)
	# blabla is true
	do.something()

Another idea that has been put forward is to simply include the entire
source, as entered, with the function, but that has drawbacks in case
the function gets modified by directly accessing the parse tree and
whatnot. 

My current hunch is that one needs to have multiple attributes (e.g.
"pre-comment", "post-comment", "endline-comment", "else-comment",....)
and have deparse print them accordingly. Not quite sure how to keep
track of that during parsing, though....

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._