Replies: 1 comment 6 replies
-
You bring up a good idea, and I agree. Implemented in efa5da8. Does that help? I originally had trouble with |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Help
Description
I just discovered
tar_source()
recently, and ran into a small issue. Previously I usedinvisible(lapply(list.files(path = "R" pattern = "*.R", full.names = TRUE), source))
in my pipelines. With the latter approach it is possible to interactively debug functions sourced fromR/
while having the debugger step through the source file. Meanwhiletar_source
reads the scripts and then useseval(parse(text = ...))
on the resulting R character vectors, in which case R will not be able to track where a function was defined.Before @wlandau implemented
tar_source
there was some discussion on wheresource
assigns functions in #896 and sourcing in Target Markdown was changed fromsource
toeval(parse(...))
in c4f525a (although without any further explanation), so I supposesource()
can be problematic.But AFAIU using the
file
argument ofparse()
could work. It keeps the reference to the source files while having the ability to specify an environment, like this intar_source
:Of course,
change_directory
needs to be accommodated.parse()
already usesreadLines(..., warn = FALSE)
so that's taken care of.Would there be any drawbacks of such a change? Happy to open a PR if you think it's OK.
Beta Was this translation helpful? Give feedback.
All reactions