Re: [Rd] calls with comment attribute

2019-11-28 Thread Tomas Kalibera



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 case, now comments are part of source references.


Best
Tomas

On 11/13/19 4:15 AM, William Dunlap via R-devel wrote:

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., 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)), comment=c("a comment", "another

comment"))

 a comment
 another comment
 func(arg)

What is the rationale for the special treatment of calls?

It was there in revision 2 of src/main/deparse.c in 1997.  (For those
unfamiliar with R history:  the current revision of R is 77405.  That
particular file has been revised 248 times since rev 2.)

I suspect either nobody has noticed it before, or nobody had the nerve
to touch it.

Duncan Murdoch


[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] calls with comment attribute

2019-11-13 Thread peter dalgaard
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 out in a sensible 
position. After the keep.source changes, we didn't use comment() attributes 
anymore but print/deparse still acts on them. A peek at gram.y from an early R 
version should reveal the mechanism used then.

GB: presumably the comment character was considered part of the comment and 
stored with it, which is why it isn't added for printing.

-pd

> On 13 Nov 2019, at 04:15 , William Dunlap via R-devel  
> wrote:
> 
> 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., 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)), comment=c("a comment", "another
>> comment"))
>>>a comment
>>>another comment
>>>func(arg)
>>> 
>>> What is the rationale for the special treatment of calls?
>> 
>> It was there in revision 2 of src/main/deparse.c in 1997.  (For those
>> unfamiliar with R history:  the current revision of R is 77405.  That
>> particular file has been revised 248 times since rev 2.)
>> 
>> I suspect either nobody has noticed it before, or nobody had the nerve
>> to touch it.
>> 
>> Duncan Murdoch
>> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] calls with comment attribute

2019-11-12 Thread William Dunlap via R-devel
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., 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)), comment=c("a comment", "another
> comment"))
> > a comment
> > another comment
> > func(arg)
> >
> > What is the rationale for the special treatment of calls?
>
> It was there in revision 2 of src/main/deparse.c in 1997.  (For those
> unfamiliar with R history:  the current revision of R is 77405.  That
> particular file has been revised 248 times since rev 2.)
>
> I suspect either nobody has noticed it before, or nobody had the nerve
> to touch it.
>
> Duncan Murdoch
>

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] calls with comment attribute

2019-11-12 Thread Duncan Murdoch

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)), comment=c("a comment", "another comment"))
a comment
another comment
func(arg)

What is the rationale for the special treatment of calls?


It was there in revision 2 of src/main/deparse.c in 1997.  (For those 
unfamiliar with R history:  the current revision of R is 77405.  That 
particular file has been revised 248 times since rev 2.)


I suspect either nobody has noticed it before, or nobody had the nerve 
to touch it.


Duncan Murdoch

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] calls with comment attribute

2019-11-12 Thread Gabriel Becker
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 expected to
be in the values of the comment attribute?

Anyway, just a guess.

Best,
~G

On Tue, Nov 12, 2019 at 2:02 PM William Dunlap via R-devel <
r-devel@r-project.org> 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)), comment=c("a comment", "another comment"))
>a comment
>another comment
>func(arg)
>
> What is the rationale for the special treatment of calls?
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
> [[alternative HTML version deleted]]
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] calls with comment attribute

2019-11-12 Thread William Dunlap via R-devel
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
   another comment
   func(arg)

What is the rationale for the special treatment of calls?

Bill Dunlap
TIBCO Software
wdunlap tibco.com

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel