Skip to content
Prev 23355 / 63424 Next

substitute creates an object which prints incorrectly (PR#9427)

Bill.Venables at csiro.au wrote:
Yes, dumping is the serious issue here. One should also consider that 
inconsistencies can be created by other means than substitute(), e.g. by 
brute force.
The whole source attribute construction was created because there was no 
way (that we could find, anyway) to make comment and whitespace handling 
sane without either changing the language or making the parser insanely 
complicated. Old R hacks will remember how comments intended for the end 
of a for loop could move to the top when the function was listed.

The basic issue is that S's syntactic sugar coat was modeled on C, but C 
is a compiled language, so its parsers just skip comments and 
whitespace. Trying to retain comments leads to complications.... Even in 
a simple function call f(a=b), there are 7 places to stick in comments, 
so at the very least you need to deal with pre-comments, post-comments, 
and sometimes in-the-middle-comments. And what is worse, there are 
ambiguities, which make automatic parser generators unhappy: Does a 
comment between two expressions belong with the former or the latter? Etc...
Actually, this is the easier fix to my mind. Where do you see the danger?