-
Notifications
You must be signed in to change notification settings - Fork 59
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
Wrapper has the same interface as the wrapped function #14
Conversation
Now complete, including revdep-check. If the memoized function is not yet defined during memoization, its formals cannot be queried, and the old implementation is used (with a warning). Ironically, the package that pointed me at that issue -- lubridate -- doesn't use memoise anymore. (It still fails, but this is due to locale settings on my machine.) The individual merges (excluding trivial ones, oldest first) provide additional detail. |
memoise <- memoize <- function(f) { | ||
memoise <- memoize <- function(f, envir = parent.frame()) { | ||
# We must not even try evaluating f -- once we start, there's no way back | ||
if (inherits(try(eval.parent(substitute(f)), silent = TRUE), "try-error")) { |
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.
Is there a reason you don't want to use exists here?
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.
I think exists()
won't work with anonymous functions.
Incorporate review notes
Thanks for the review, I have addressed all remarks. The most recent changes are https://github.com/krlmlr/memoise/pull/16/files. |
Just updated the revdep check. Hope there won't be too many conflicts with @jimhester's pull requests. |
Thanks Kirill, this makes the interface much nicer! |
Also, the wrapped function is referred to by
memoised_function
, which is clearer thanf
.Cc @maxheld83 and @piccolbo.
Fixes #12.
Fixes #6.
Closes #7 (=supersedes it).
Closes #2 (=includes it).
Closes #13 (=includes it).
Example: