-
Notifications
You must be signed in to change notification settings - Fork 978
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
Don't use function string matching for do.call(what=) or lapply(FUN=) #6217
Conversation
Generated via commit 6fb1c1f Download link for the artifact containing the test results: ↓ atime-results.zip Time taken to finish the standard R installation steps: 12 minutes and 29 seconds Time taken to run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, thanks
LGTM, but I'm not sure I would apply it to test cases since some of them might explictly check for working with characters, as e.g., 23c88e7 |
Thanks for flagging! Indeed I skipped some test cases that are testing for strings usage specifically. In general you're right that altering test cases can be risky. Those changes I did include are clearly designed to test other things -- if behavior w.r.t. strings is intended, that should get its own specific test. The footprint here is small enough I'm confident we're OK. |
Related: #6192. First caught my eye because I know this makes it harder for static analyzers, e.g. any code looking for
cbind()
usage will have to special-case the possibility thatcbind
is passed as a string, in an appropriate context, etc.This is not a terribly big deal for base functions but is best practice when using dependencies since it can be hard to tell if downstreams get broken, statically.
It's also a bit slower --
match.fun()
exits immediately when passed a function, takes an extra step when passed a string. That core part of function matching inlapply()
is 10x slower.do.call()
is roughly the same:PS Shouldn't we use
NextMethod()
, rather than call the S3 method explicitly?