[Rd] AddComment (gram.y)

Peter Dalgaard p.dalgaard at biostat.ku.dk
Sun Apr 20 09:26:50 CEST 2008


>     >> anyone object to bringing it back?
>     >> 
>     DM> Yes, I would.  
>
> and so would probably almost everyone in R-core.
> We *did* think already back in the last millennium...
> and removed them for a good reason
> {IIRC, because there were always cases where they were attached
>  to the wrong expression, and we were more or less convinced,
>  there was no to do it "right" in all cases}.
>
>   
Yes. Well, there was no _obvious_ way to do it right. If someone sets 
out to do it right, we might want the result, but it is definitely not 
as easy as reinstating the 1999 code, which would do fun stuff like 
moving end-loop comments to the start of the loop (and in glm.fit, the 
end-loop comment was, and still is, "## -- end IRLS iteration --"!!). It 
requires a substantial parser rewrite.

The main issue is that  you wold need the parser to retain more 
information about the textual layout of its input, probably not only 
about the comments, but also about line breaks. If you consider 
moderately complex syntactical structures, like for loops and switch 
expressions, all the points where  you could potentially insert a 
comment or break the line, and then try to insert that information in 
the parse tree, chances are you come out utterly confused. Notice, in 
particular, that everything is ambiguous, if you have two successive 
expressions and a comment on the line in between, does it belong with 
the former or the latter expression? And what about

plot(
   x=foo, # abscissa
   y=bar  # ordinate
)


-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907



More information about the R-devel mailing list