[Rd] Problems with new srcref warnings in R 2.14 (development)

Vitalie Spinu spinuvit at gmail.com
Sat Nov 19 12:28:15 CET 2011


Dear R developers,

Print method for function now tries to open the source file associated
with srcref of the function.

It outputs only the warning, if file cannot be open,  and forgets to
print the function definition.

Example:

eval(parse(text = "tf <- function(a){
    b <- a^4
    b
}",  srcfile = srcfile("xxx at 17")))

> tf
<srcref: file "xxx at 17" chars 1:7 to 4:1>
Warning message:
In file(srcfile$filename, open = "rt", encoding = encoding) :
  cannot open file 'xxx at 17': No such file or directory

First, the function definition is not printed and I assume it's a bug.
Second, the warning might not be appropriate.
For example ESS with the latest  ess-tracebug
(http://code.google.com/p/ess-tracebug/) inserts srcref into the
function on the fly.
Srcfile is of the form file_name at index where index is used to find the
function definition afterwards.

This is useful for two reasons:
-- the visual debugger knows about the reference and  jumps through
the function even if the file was not sourced
-- any typos/errors in the code are reported by R with the source
reference, so that the  editor can automatically jump to the error
location.

Can please an option to suppress the warnings or even better suppress
the srcfile validity checks  be implemented?

Thanks,
Vitalie.

sessionInfo()
R Under development (unstable) (2011-11-15 r57665)
Platform: i686-pc-linux-gnu (32-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
LC_TIME=en_US.UTF-8
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8
LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=C                 LC_NAME=C
LC_ADDRESS=C
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base
>



More information about the R-devel mailing list