Description
To solve #38, which is different functions have same parameters (including empty parameter), body of the function to be memoised is introduced in digest in 70d959b
To solve #58 #61, which is srcref will differ across sources, including different computers, body of the function is converted to character in 611cfad
However, when two functions are identical except of their enclosing environments, problem arises
fn <- function(x) function(y) x+y
digest::digest(fn(1))
digest::digest(fn(2))
digest::digest(body(fn(1)))
digest::digest(body(fn(2)))
As examples above demonstrate, the two functions have different digests themselves, but identical digest of the bodies
As there is a function called removeSource in utils, which exactly removes all source related attributes of a function, it might be appropriate to use removeSource(fn) instead of as.character(body(fn))
digest::digest(utils::removeSource(fn(1)))
digest::digest(utils::removeSource(fn(2)))