From p.dalgaard at biostat.ku.dk  Sun Apr 20 09:26:50 2008
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: Sun, 20 Apr 2008 09:26:50 +0200
Subject: [Rd] AddComment (gram.y)
In-Reply-To: <18442.25443.49716.190470@stat.math.ethz.ch>
References: <20080419050915.GA1820@klutometis.wikitex.org>	<4809D46D.2030308@stats.uwo.ca>	<20080419185707.GA10684@klutometis.wikitex.org>	<480A5A28.60302@stats.uwo.ca>
	<18442.25443.49716.190470@stat.math.ethz.ch>
Message-ID: <480AF03A.1010407@biostat.ku.dk>


>     >> 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



[Rd] AddComment (gram.y)
Peter Dalgaard