Thanks for spotting this, I've removed the old code in deparse so that
now the comment attribute is really not printed, as documented in
?comment. The removed code was needed at the time when comments were
collected by the parser and stored in the comment attribute, but that is
no longer the
I think this is spot on. I remember all sorts of silliness when deparsing
expressions while trying to retain comments - comments moving from beginning to
end of loops or vice versa, that sort of thing. It was pretty much impossible
to stick comments into the parse tree and have them come back ou
I suspect that the parser used it to store comments, including the initial
"#", before R started using the srcref attribute. (S also stored comments
in the parse tree.)
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, Nov 12, 2019 at 4:16 PM Duncan Murdoch
wrote:
> On 12/11/2019 5:01 p.m.
On 12/11/2019 5:01 p.m., William Dunlap via R-devel wrote:
In general R doesn't print the "comment" attribute of an object
> structure(1:3, comment=c("a comment", "another comment"))
[1] 1 2 3
but if the object is a call it prints it in an unusual format
> structure(quote(func(arg)),
Bill,
Without being involved in that code at all, it seems that this could be
used to (re)create commented source code from R objects. That format seems
to correspond directly to a call in a .R file with two comments above it. A
bit weird there's no comment character there but I guess thats expect
In general R doesn't print the "comment" attribute of an object
> structure(1:3, comment=c("a comment", "another comment"))
[1] 1 2 3
but if the object is a call it prints it in an unusual format
> structure(quote(func(arg)), comment=c("a comment", "another comment"))
a comment
anoth