Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clarification on srcref and function f #36

Open
piccolbo opened this issue Mar 27, 2015 · 1 comment
Open

clarification on srcref and function f #36

piccolbo opened this issue Mar 27, 2015 · 1 comment

Comments

@piccolbo
Copy link

I was wondering if there is a simple explanation why functions created with function have a srcref attribute, whereas function created with f don't, but their bodies do. To add a touch of mystery, using f in a do.call inside another function makes even the body attributes go away. That means it's hard to use covr with pryr as the srcref attribute is used in that library. It'd be nice if function and f were absolutely interchangeable, in an ideal world. Thanks

library(pryr)
fplain = function(x) {x}
ff = f(x, {x})
f.do.call = function(...) do.call(f, c(dots(...), .env = parent.frame()))
fff = f.do.call(x, {x})
attributes(fplain)
# $srcref
# function(x) {x}
attributes(ff)
# NULL
attributes(fff)
# NULL
attributes(body(fplain))
# $srcref
# $srcref[[1]]
# {
# $srcref[[2]]
# x
# $srcfile
# $wholeSrcref
# fplain = function(x) {x}
attributes(body(ff))
# $srcref
# $srcref[[1]]
# {
# $srcref[[2]]
# x
# $srcfile
# $wholeSrcref
# ff = f(x, {x}
attributes(body(fff))
# NULL
@piccolbo
Copy link
Author

it seems dots exacts an attribute tax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant