Open HenrikBengtsson opened 4 years ago
What's not clear to me is whether pathname <- utils::getSrcFilename(x, full.names = TRUE)
can ever return more than one filename, i.e. length(pathname) > 1
? Likewise, can line <- utils::getSrcLocation(x, which = "line")
ever return more than one line index, i.e. length(line) > 1
?
This needs to be figured out before proposing a patch to base R.
Is Bug 17968 - removeSource doesn't completely remove srcrefs for nested functions relevant here, i.e. the fact that there can be nested source references?
When a function is defined in a script and we
source()
the script, the function carry "srcref" attributes with details on the script file location and on what lines in that file the function was defined. It would be useful haveprint()
display this information for functions, e.g.Not all functions carry this information, e.g. functions part of a package do not have this information, e.g.
Prototype
The current implementation is:
This can easily be extended to print "srcref" information afterward, e.g.
Try it
To test the above
print.function()
, just add it to~/.Rprofile
wrapped in aif (interactive()) { ... }
, or as-is to~/.Rprofile.d/interactive=TRUE/print.function.R
if you use startup.See also